Class: Optimus::ParsedCalculator::Evaluators::ArgList
- Inherits:
-
Object
- Object
- Optimus::ParsedCalculator::Evaluators::ArgList
- Includes:
- Enumerable
- Defined in:
- lib/expression_parser/evaluators.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #all_num? ⇒ Boolean
- #bool_cast ⇒ Object
- #cast_for_comparison ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(*args) ⇒ ArgList
constructor
A new instance of ArgList.
Constructor Details
#initialize(*args) ⇒ ArgList
Returns a new instance of ArgList.
18 19 20 |
# File 'lib/expression_parser/evaluators.rb', line 18 def initialize(*args) @args = args end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
17 18 19 |
# File 'lib/expression_parser/evaluators.rb', line 17 def args @args end |
Instance Method Details
#all_num? ⇒ Boolean
26 27 28 |
# File 'lib/expression_parser/evaluators.rb', line 26 def all_num? @args.all? {|v| v.kind_of? Numeric } end |
#bool_cast ⇒ Object
34 35 36 |
# File 'lib/expression_parser/evaluators.rb', line 34 def bool_cast @args.map {|v| v.to_s.strip == '' ? false : v } end |
#cast_for_comparison ⇒ Object
30 31 32 |
# File 'lib/expression_parser/evaluators.rb', line 30 def cast_for_comparison @args.map {|v| floatify(v) } end |
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/expression_parser/evaluators.rb', line 22 def each(&block) @args.each(&block) end |