Class: RDF::Query::HashPatternNormalizer::Counter

Inherits:
Object
  • Object
show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb

Overview

A counter that can be incremented and decremented.

Since:

  • 0.3.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(offset = 0, increment = 1) ⇒ Counter

Returns a new instance of Counter.

Parameters:

  • offset (Numeric) (defaults to: 0)

    the offset (or initial value) for this counter.

  • increment (Numeric) (defaults to: 1)

    the increment for this counter.

Since:

  • 0.3.0



25
26
27
28
29
30
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 25

def initialize(offset = 0, increment = 1)
  @offset = offset
  @increment = increment
  
  @value = @offset
end

Instance Attribute Details

#incrementNumeric (readonly)

The increment for this counter.

Returns:

  • (Numeric)

Since:

  • 0.3.0



18
19
20
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 18

def increment
  @increment
end

#offsetNumeric (readonly)

The offset (or initial value) for this counter.

Returns:

  • (Numeric)

Since:

  • 0.3.0



12
13
14
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 12

def offset
  @offset
end

Instance Method Details

#decrement!RDF::Query::HashPatternNormalizer::Counter

Decrements this counter, and returns the new value.



36
37
38
39
40
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 36

def decrement!
  @value -= @increment
  
  self
end

#increment!RDF::Query::HashPatternNormalizer::Counter

Increments this counter, and returns the new value.



46
47
48
49
50
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 46

def increment!
  @value += @increment
  
  self
end

#to_fFloat

Returns a floating point representation of this counter.

Returns:

Since:

  • 0.3.0



56
57
58
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 56

def to_f
  @value.to_f
end

#to_iInteger

Returns an integer representation of this counter.

Returns:

Since:

  • 0.3.0



64
65
66
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 64

def to_i
  @value.to_i
end

#to_sString

Returns a string representation of this counter.

Returns:

Since:

  • 0.3.0



71
72
73
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-884e3ef78084/lib/rdf/query/hash_pattern_normalizer.rb', line 71

def to_s
  @value.to_s
end