Method: Fable::FloatValue#cast

Defined in:
lib/fable/value.rb

#cast(new_type) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fable/value.rb', line 101

def cast(new_type)
  if new_type == self.class
    return self
  end

  if new_type == IntValue
    return IntValue.new(self.value.to_i)
  end

  if new_type == StringValue
    return StringValue.new(self.value.to_s)
  end

  raise bad_cast_exception(new_type)
end