Class: Commons::Lang::Time::DurationFormatUtils::Token
- Inherits:
-
Object
- Object
- Commons::Lang::Time::DurationFormatUtils::Token
- Defined in:
- lib/commons/lang/time/duration_format_utils.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #increment ⇒ Object
-
#initialize(value, count = 1) ⇒ Token
constructor
A new instance of Token.
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(value, count = 1) ⇒ Token
Returns a new instance of Token.
221 222 223 224 225 226 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 221 def initialize(value, count = 1) super() @value = value @count = count end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
209 210 211 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 209 def count @count end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
209 210 211 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 209 def value @value end |
Class Method Details
.contains_token_with_value?(tokens, value) ⇒ Boolean
211 212 213 214 215 216 217 218 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 211 def self.contains_token_with_value?(tokens, value) tokens.each {|token| if token.value.equal?(value) return true end } return false end |
Instance Method Details
#==(other) ⇒ Object
234 235 236 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 234 def ==(other) return self.eql?(other) end |
#eql?(other) ⇒ Boolean
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 239 def eql?(other) if other.kind_of?(Token) if !@value.class.equal?(other.value.class) return false end if @count != other.count return false end if @value.kind_of?(String) return @value.to_s == other.value.to_s elsif @value.kind_of?(Numeric) return @value == other.value else return @value.equal?(other.value) end end return false end |
#hash ⇒ Object
260 261 262 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 260 def hash return @value.hash end |
#increment ⇒ Object
229 230 231 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 229 def increment @count += 1 end |
#to_s ⇒ Object
265 266 267 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 265 def to_s return @value.to_s * @count end |
#to_str ⇒ Object
270 271 272 |
# File 'lib/commons/lang/time/duration_format_utils.rb', line 270 def to_str return self.to_s end |