Class: Constant::Literal
- Inherits:
-
Object
show all
- Includes:
- Constant, Initializer
- Defined in:
- lib/constant/literal.rb
Constant Summary
Constants included
from Constant
Error
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Constant
#==, __name, defined?, #eql?, get, #hash, name, namespace
Class Method Details
.build(name, value, namespace) ⇒ Object
8
9
10
11
12
|
# File 'lib/constant/literal.rb', line 8
def self.build(name, value, namespace)
name = name.to_s
namespace = Constant::Module.build(namespace)
new(name, value, namespace)
end
|
Instance Method Details
#constants(inherit: nil) ⇒ Object
26
27
28
|
# File 'lib/constant/literal.rb', line 26
def constants(inherit: nil)
[]
end
|
#defined?(name_or_module, inherit: nil) ⇒ Boolean
34
35
36
|
# File 'lib/constant/literal.rb', line 34
def defined?(name_or_module, inherit: nil)
false
end
|
#full_name ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/constant/literal.rb', line 14
def full_name
if namespace.value.equal?(Object)
name
else
"#{namespace.full_name}::#{name}"
end
end
|
#get(name, inherit: nil) ⇒ Object
30
31
32
|
# File 'lib/constant/literal.rb', line 30
def get(name, inherit: nil)
raise Constant::Error, "Literal constants are primitive values. They don't support inner constants. #{name} is not defined in #{full_name}."
end
|
#identity ⇒ Object
22
23
24
|
# File 'lib/constant/literal.rb', line 22
def identity
full_name
end
|