Class: Fable::IntValue
- Inherits:
-
Value
- Object
- RuntimeObject
- Value
- Fable::IntValue
- Defined in:
- lib/fable/value.rb
Instance Attribute Summary
Attributes inherited from Value
Attributes inherited from RuntimeObject
#original_object, #own_debug_metadata, #parent, #path
Instance Method Summary collapse
- #cast(new_type) ⇒ Object
-
#initialize(value = 0) ⇒ IntValue
constructor
A new instance of IntValue.
- #truthy? ⇒ Boolean
- #value_type ⇒ Object
Methods inherited from Value
#bad_cast_exception, #copy, create, #to_s
Methods inherited from RuntimeObject
#compact_path_string, #convert_path_to_relative, #copy, #debug_line_number_of_path, #debug_metadata, #indentation_string, #resolve_path, #root_content_container
Constructor Details
#initialize(value = 0) ⇒ IntValue
Returns a new instance of IntValue.
67 68 69 |
# File 'lib/fable/value.rb', line 67 def initialize(value=0) super(value) end |
Instance Method Details
#cast(new_type) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fable/value.rb', line 71 def cast(new_type) if new_type == self.class return self end if new_type == FloatValue return FloatValue.new(self.value.to_f) end if new_type == StringValue return StringValue.new(self.value.to_s) end raise bad_cast_exception(new_type) end |
#truthy? ⇒ Boolean
63 64 65 |
# File 'lib/fable/value.rb', line 63 def truthy? return value != 0 end |
#value_type ⇒ Object
59 60 61 |
# File 'lib/fable/value.rb', line 59 def value_type return OrderedValueTypes[IntValue] end |