class MapValuesToCStructs
Public Instance Methods
map(ast)
click to toggle source
# File src/compile/c/map_values_to_c_structs.rb, line 5 def map(ast) if ast.is_a?(Array) operator = ast[0] if respond_to?(operator) send(operator,*ast[1..-1]) else raise NotSupportedException.new("#{operator} in #{ast.inspect} not supported") end else raise NotSupportedException.new("#{ast} not supported") end end
number(text)
click to toggle source
# File src/compile/c/map_values_to_c_structs.rb, line 18 def number(text) n = case text.to_s when /\./ text.to_f.to_s when /e/i text.to_f.to_s else text.to_i.to_s end "{.type = ExcelNumber, .number = #{n}}" end
percentage(text)
click to toggle source
# File src/compile/c/map_values_to_c_structs.rb, line 30 def percentage(text) "{.type = ExcelNumber, .number = #{(text.to_f / 100.0).to_s}}" end
string(text)
click to toggle source
# File src/compile/c/map_values_to_c_structs.rb, line 34 def string(text) "{.type = ExcelString, .string = #{text.inspect}}" end