Class: Birddog::NumericExpression
- Inherits:
-
Object
- Object
- Birddog::NumericExpression
- Defined in:
- lib/birddog/numeric_expression.rb
Instance Method Summary collapse
-
#initialize(value, type) ⇒ NumericExpression
constructor
A new instance of NumericExpression.
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, type) ⇒ NumericExpression
Returns a new instance of NumericExpression.
5 6 7 8 9 10 11 |
# File 'lib/birddog/numeric_expression.rb', line 5 def initialize(value, type) value.gsub!(/\s/, '') parts = value.scan(/(?:[=<>~]+|(?:-?\d|\.)+)/)[0,2] @value = Float(parts.last) @value = @value.to_i if type == :integer end |
Instance Method Details
#to_f ⇒ Object
17 18 19 |
# File 'lib/birddog/numeric_expression.rb', line 17 def to_f @value.to_f end |
#to_i ⇒ Object
13 14 15 |
# File 'lib/birddog/numeric_expression.rb', line 13 def to_i @value.to_i end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/birddog/numeric_expression.rb', line 21 def to_s @value.to_s end |