Class: Fable::Value
Instance Attribute Summary collapse
#original_object, #own_debug_metadata, #parent, #path
Class Method Summary
collapse
Instance Method Summary
collapse
#compact_path_string, #convert_path_to_relative, #debug_line_number_of_path, #debug_metadata, #indentation_string, #resolve_path, #root_content_container
Constructor Details
#initialize(value) ⇒ Value
Returns a new instance of Value.
8
9
10
11
|
# File 'lib/fable/value.rb', line 8
def initialize(value)
super()
self.value_object = value
end
|
Instance Attribute Details
#value_object ⇒ Object
Also known as:
value
Returns the value of attribute value_object.
3
4
5
|
# File 'lib/fable/value.rb', line 3
def value_object
@value_object
end
|
Class Method Details
.create(value) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/fable/value.rb', line 29
def self.create(value)
case value
when TrueClass, FalseClass
converted_to_int = value ? 1 : 0
return IntValue.new(converted_to_int)
when Integer
return IntValue.new(value)
when Numeric
return FloatValue.new(value.to_f)
when String
return StringValue.new(value)
when Path
return DivertTargetValue.new(value)
when InkList
return ListValue.new(value)
else
return nil
end
end
|
Instance Method Details
#bad_cast_exception(target_type) ⇒ Object
53
54
55
|
# File 'lib/fable/value.rb', line 53
def bad_cast_exception(target_type)
return StoryError.new("Can't cast #{self.value_object} from #{OrderedValueTypes.key(self.value_type)} to #{target_type}")
end
|
#cast(new_type) ⇒ Object
21
22
23
|
# File 'lib/fable/value.rb', line 21
def cast(new_type)
raise NotImplementedError
end
|
#copy ⇒ Object
49
50
51
|
# File 'lib/fable/value.rb', line 49
def copy
return self.class.create(value_object)
end
|
#to_s ⇒ Object
25
26
27
|
# File 'lib/fable/value.rb', line 25
def to_s
value_object.to_s
end
|
#truthy? ⇒ Boolean
17
18
19
|
# File 'lib/fable/value.rb', line 17
def truthy?
raise NotImplementedError
end
|
#value_type ⇒ Object
13
14
15
|
# File 'lib/fable/value.rb', line 13
def value_type
raise NotImplementedError
end
|