Class: Uinit::Type::Const
- Inherits:
-
Base
- Object
- Base
- Uinit::Type::Const
show all
- Defined in:
- lib/uinit/type/const.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, [], #is!, #to_s, #trace!, #type_error!
Methods included from Operators
#&, #|
Constructor Details
#initialize(value) ⇒ Const
Returns a new instance of Const.
14
15
16
17
18
|
# File 'lib/uinit/type/const.rb', line 14
def initialize(value)
super()
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
20
21
22
|
# File 'lib/uinit/type/const.rb', line 20
def value
@value
end
|
Class Method Details
.from(val) ⇒ Object
10
11
12
|
# File 'lib/uinit/type/const.rb', line 10
def self.from(val)
new(val) if from?(val)
end
|
.from?(_val) ⇒ Boolean
6
7
8
|
# File 'lib/uinit/type/const.rb', line 6
def self.from?(_val)
true
end
|
Instance Method Details
#check!(value, depth) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/uinit/type/const.rb', line 26
def check!(value, depth)
return value if is?(value)
type_error!(
"#{value.inspect} must be equal to #{self.value.inspect}",
depth
)
end
|
#inspect ⇒ Object
35
36
37
|
# File 'lib/uinit/type/const.rb', line 35
def inspect
"#{super}[#{value.inspect}]"
end
|
#is?(value) ⇒ Boolean
22
23
24
|
# File 'lib/uinit/type/const.rb', line 22
def is?(value)
self.value == value
end
|