Class: Stretto::Value::NumericValue

Inherits:
Object
  • Object
show all
Defined in:
lib/stretto/music_elements/modifiers/value.rb

Overview

Wraps a numeric value

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(numeric) ⇒ NumericValue

Returns a new instance of NumericValue.

Parameters:

  • The (Number)

    numeric value held



19
20
21
# File 'lib/stretto/music_elements/modifiers/value.rb', line 19

def initialize(numeric)
  @numeric = numeric
end

Instance Attribute Details

#numericObject (readonly)

Returns the value of attribute numeric.



16
17
18
# File 'lib/stretto/music_elements/modifiers/value.rb', line 16

def numeric
  @numeric
end

Instance Method Details

#==(other) ⇒ Boolean

Returns True if the value it is holding is equal to other’s value.

Returns:

  • (Boolean)

    True if the value it is holding is equal to other’s value



34
35
36
# File 'lib/stretto/music_elements/modifiers/value.rb', line 34

def ==(other)
  other.kind_of?(NumericValue) && other.numeric == @numeric
end

#to_f(pattern) ⇒ Float

Returns The numeric value coerced to a float.

Returns:

  • (Float)

    The numeric value coerced to a float



29
30
31
# File 'lib/stretto/music_elements/modifiers/value.rb', line 29

def to_f(pattern)
  @numeric.to_f
end

#to_i(pattern) ⇒ Integer

Returns The numeric value coerced to an integer.

Returns:

  • (Integer)

    The numeric value coerced to an integer



24
25
26
# File 'lib/stretto/music_elements/modifiers/value.rb', line 24

def to_i(pattern)
  @numeric.to_i
end

#to_sString

Returns The string representation of the numeric value.

Returns:

  • (String)

    The string representation of the numeric value



39
40
41
# File 'lib/stretto/music_elements/modifiers/value.rb', line 39

def to_s
  @numeric.to_s
end