class Fable::FloatValue

Public Class Methods

new(value = 0.0) click to toggle source
Calls superclass method Fable::Value::new
# File lib/fable/value.rb, line 97
def initialize(value = 0.0)
  super(value)
end

Public Instance Methods

cast(new_type) click to toggle source
# 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
to_s() click to toggle source
# File lib/fable/value.rb, line 117
def to_s
  if value % 1 == 0
    value.to_i.to_s
  else
    value.round(7).to_s
  end
end
truthy?() click to toggle source
# File lib/fable/value.rb, line 93
def truthy?
  return value != 0.0
end
value_type() click to toggle source
# File lib/fable/value.rb, line 89
def value_type
  return FloatValue
end