Class: Odin::Types::OdinValue
- Inherits:
-
Object
- Object
- Odin::Types::OdinValue
show all
- Defined in:
- lib/odin/types/values.rb
Direct Known Subclasses
OdinArray, OdinBinary, OdinBoolean, OdinCurrency, OdinDate, OdinDuration, OdinInteger, OdinNull, OdinNumber, OdinObject, OdinPercent, OdinReference, OdinString, OdinTime, OdinTimestamp, OdinVerbExpression
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(modifiers: nil, directives: []) ⇒ OdinValue
Returns a new instance of OdinValue.
11
12
13
14
|
# File 'lib/odin/types/values.rb', line 11
def initialize(modifiers: nil, directives: [])
@modifiers = modifiers
@directives = directives.freeze
end
|
Instance Attribute Details
#directives ⇒ Object
Returns the value of attribute directives.
9
10
11
|
# File 'lib/odin/types/values.rb', line 9
def directives
@directives
end
|
#modifiers ⇒ Object
Returns the value of attribute modifiers.
9
10
11
|
# File 'lib/odin/types/values.rb', line 9
def modifiers
@modifiers
end
|
Instance Method Details
#array? ⇒ Boolean
36
|
# File 'lib/odin/types/values.rb', line 36
def array?; type == ValueType::ARRAY; end
|
#binary? ⇒ Boolean
34
|
# File 'lib/odin/types/values.rb', line 34
def binary?; type == ValueType::BINARY; end
|
#boolean? ⇒ Boolean
21
|
# File 'lib/odin/types/values.rb', line 21
def boolean?; type == ValueType::BOOLEAN; end
|
#confidential? ⇒ Boolean
17
|
# File 'lib/odin/types/values.rb', line 17
def confidential?; modifiers&.confidential || false; end
|
#currency? ⇒ Boolean
25
|
# File 'lib/odin/types/values.rb', line 25
def currency?; type == ValueType::CURRENCY; end
|
#date? ⇒ Boolean
29
|
# File 'lib/odin/types/values.rb', line 29
def date?; type == ValueType::DATE; end
|
#deprecated? ⇒ Boolean
18
|
# File 'lib/odin/types/values.rb', line 18
def deprecated?; modifiers&.deprecated || false; end
|
#duration? ⇒ Boolean
32
|
# File 'lib/odin/types/values.rb', line 32
def duration?; type == ValueType::DURATION; end
|
#integer? ⇒ Boolean
23
|
# File 'lib/odin/types/values.rb', line 23
def integer?; type == ValueType::INTEGER; end
|
#null? ⇒ Boolean
20
|
# File 'lib/odin/types/values.rb', line 20
def null?; type == ValueType::NULL; end
|
#number? ⇒ Boolean
24
|
# File 'lib/odin/types/values.rb', line 24
def number?; type == ValueType::NUMBER; end
|
#numeric? ⇒ Boolean
27
|
# File 'lib/odin/types/values.rb', line 27
def numeric?; %i[integer number currency percent].include?(type); end
|
#object? ⇒ Boolean
37
|
# File 'lib/odin/types/values.rb', line 37
def object?; type == ValueType::OBJECT; end
|
#percent? ⇒ Boolean
26
|
# File 'lib/odin/types/values.rb', line 26
def percent?; type == ValueType::PERCENT; end
|
#reference? ⇒ Boolean
33
|
# File 'lib/odin/types/values.rb', line 33
def reference?; type == ValueType::REFERENCE; end
|
#required? ⇒ Boolean
16
|
# File 'lib/odin/types/values.rb', line 16
def required?; modifiers&.required || false; end
|
#string? ⇒ Boolean
22
|
# File 'lib/odin/types/values.rb', line 22
def string?; type == ValueType::STRING; end
|
#temporal? ⇒ Boolean
28
|
# File 'lib/odin/types/values.rb', line 28
def temporal?; %i[date timestamp time duration].include?(type); end
|
#time? ⇒ Boolean
31
|
# File 'lib/odin/types/values.rb', line 31
def time?; type == ValueType::TIME; end
|
#timestamp? ⇒ Boolean
30
|
# File 'lib/odin/types/values.rb', line 30
def timestamp?; type == ValueType::TIMESTAMP; end
|
#verb? ⇒ Boolean
35
|
# File 'lib/odin/types/values.rb', line 35
def verb?; type == ValueType::VERB; end
|
#with_directives(dirs) ⇒ Object
43
44
45
|
# File 'lib/odin/types/values.rb', line 43
def with_directives(dirs)
raise NotImplementedError, "Subclass must implement #with_directives"
end
|
#with_modifiers(mods) ⇒ Object
39
40
41
|
# File 'lib/odin/types/values.rb', line 39
def with_modifiers(mods)
raise NotImplementedError, "Subclass must implement #with_modifiers"
end
|