Class: FilterParam::AST::Literal
- Defined in:
- lib/filter_param/ast/literal.rb
Direct Known Subclasses
FilterParam::AST::Literals::Boolean, FilterParam::AST::Literals::Date, FilterParam::AST::Literals::Integer, FilterParam::AST::Literals::Null, FilterParam::AST::Literals::String
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value = nil) ⇒ Literal
constructor
A new instance of Literal.
- #type_cast(type) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(value = nil) ⇒ Literal
Returns a new instance of Literal.
6 7 8 |
# File 'lib/filter_param/ast/literal.rb', line 6 def initialize(value = nil) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/filter_param/ast/literal.rb', line 4 def value @value end |
Instance Method Details
#type_cast(type) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/filter_param/ast/literal.rb', line 10 def type_cast(type) return self if type.blank? cast_method = "to_#{type}" return send(cast_method) if respond_to?(cast_method, true) raise InvalidLiteral.new("Cannot cast '#{value}' to #{type}") end |