Class: RDF::Query::HashPatternNormalizer::Counter
- 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.
Instance Attribute Summary collapse
-
#increment ⇒ Numeric
readonly
The increment for this counter.
-
#offset ⇒ Numeric
readonly
The offset (or initial value) for this counter.
Instance Method Summary collapse
-
#decrement! ⇒ RDF::Query::HashPatternNormalizer::Counter
Decrements this counter, and returns the new value.
-
#increment! ⇒ RDF::Query::HashPatternNormalizer::Counter
Increments this counter, and returns the new value.
-
#initialize(offset = 0, increment = 1) ⇒ Counter
constructor
A new instance of Counter.
-
#to_f ⇒ Float
Returns a floating point representation of this counter.
-
#to_i ⇒ Integer
Returns an integer representation of this counter.
-
#to_s ⇒ String
Returns a string representation of this counter.
Constructor Details
#initialize(offset = 0, increment = 1) ⇒ Counter
Returns a new instance of Counter.
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
#increment ⇒ Numeric (readonly)
The increment for this counter.
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 |
#offset ⇒ Numeric (readonly)
The offset (or initial value) for this counter.
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_f ⇒ Float
Returns a floating point representation of this counter.
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_i ⇒ Integer
Returns an integer representation of this counter.
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_s ⇒ String
Returns a string representation of this counter.
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 |