class MapValuesToC

Constants

ERRORS
REVERSE_ERRORS

Public Instance Methods

blank() click to toggle source
# File src/compile/c/map_values_to_c.rb, line 18
def blank
  "BLANK"
end
Also aliased as: null
boolean_false() click to toggle source
# File src/compile/c/map_values_to_c.rb, line 92
def boolean_false
  "FALSE"
end
boolean_true() click to toggle source
# File src/compile/c/map_values_to_c.rb, line 88
def boolean_true
  "TRUE"
end
constant(name) click to toggle source
# File src/compile/c/map_values_to_c.rb, line 26
def constant(name)
  name
end
error(text) click to toggle source
# File src/compile/c/map_values_to_c.rb, line 84
def error(text)
  ERRORS[text] || (raise NotSupportedException.new("#{text.inspect} error not recognised"))
end
inlined_blank() click to toggle source
# File src/compile/c/map_values_to_c.rb, line 22
def inlined_blank
  "BLANK"
end
map(ast) click to toggle source
# File src/compile/c/map_values_to_c.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
null()
Alias for: blank
number(text) click to toggle source

FIXME: Refactor to do proper integer check

# File src/compile/c/map_values_to_c.rb, line 33
def number(text)
  case text.to_f
  when 0; "ZERO"
  when 1; "ONE"
  when 2; "TWO"
  when 3; "THREE"
  when 4; "FOUR"
  when 5; "FIVE"
  when 6; "SIX"
  when 7; "SEVEN"
  when 8; "EIGHT"
  when 9; "NINE"
  when 10; "TEN"
  else   
    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
    "EXCEL_NUMBER(#{n})"
  end
end
percentage(text) click to toggle source
# File src/compile/c/map_values_to_c.rb, line 59
def percentage(text)
  "EXCEL_NUMBER(#{(text.to_f / 100.0).to_s})"
end
string(text) click to toggle source
# File src/compile/c/map_values_to_c.rb, line 63
def string(text)
  "EXCEL_STRING(#{text.inspect})"
end