Class: Opencdd::Cddal::AST::Literal
- Inherits:
-
Struct
- Object
- Struct
- Opencdd::Cddal::AST::Literal
- Defined in:
- lib/opencdd/cddal/ast.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind
85 86 87 |
# File 'lib/opencdd/cddal/ast.rb', line 85 def kind @kind end |
#raw ⇒ Object
Returns the value of attribute raw
85 86 87 |
# File 'lib/opencdd/cddal/ast.rb', line 85 def raw @raw end |
Instance Method Details
#to_cddal ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/opencdd/cddal/ast.rb', line 95 def to_cddal case kind when :string then "\"#{escape(raw)}\"" when :boolean, :null then raw else raw end end |
#value ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/opencdd/cddal/ast.rb', line 86 def value case kind when :number then raw.match?(/\A-?\d+\z/) ? raw.to_i : raw.to_f when :boolean then raw == "true" when :null then nil else raw end end |