Module: BlockSupport
- Includes:
- QuotedStringSupport
- Defined in:
- lib/statsailr/block_builder/sts_block.rb
Defined Under Namespace
Classes: QuotedStringR
Instance Method Summary collapse
Methods included from QuotedStringSupport
#escape_backslashes, #interpret_escape_sequences
Instance Method Details
#type_adjust(obj, type, *opts) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/statsailr/block_builder/sts_block.rb', line 79 def type_adjust(obj , type , *opts) case type when :ident if obj.is_a?(String) result = RBridge::SymbolR.new( obj ) else raise "GramNode should have string value for type(#{type.to_s})" end when :num if obj.is_a?(Integer) || obj.is_a?(Float) result = obj else raise "GramNode with inconsistent type(#{type.to_s}) and object(#{obj.class})" end when :string if obj.is_a?(String) result = obj else raise "GramNode with inconsistent type(#{type.to_s}) and object(#{obj.class})" end when :sq_string if obj.is_a?(String) unless opts.include?( :retain_input_string ) # default behavior result = obj else result = QuotedStringR.new( obj, :sq ) end else raise "GramNode with inconsistent type(#{type.to_s}) and object(#{obj.class})" end when :dq_string if obj.is_a?(String) unless opts.include?( :retain_input_string ) # default behavior result = interpret_escape_sequences( obj ) else result = QuotedStringR.new( obj, :dq ) end else raise "GramNode with inconsistent type(#{type.to_s}) and object(#{obj.class})" end when :sign if obj.is_a?(String) result = RBridge::SignR.new(obj) else raise "GramNode with inconsistent type(#{type.to_s}) and object(#{obj.class})" end end return result end |