Class: Potter::Types::Type
- Inherits:
-
Object
- Object
- Potter::Types::Type
show all
- Includes:
- OptionHelpers
- Defined in:
- lib/potter/types.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#assign_option!, #assign_options!
Constructor Details
#initialize ⇒ Type
Returns a new instance of Type.
14
15
16
|
# File 'lib/potter/types.rb', line 14
def initialize(**)
assign_options!(**)
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12
13
14
|
# File 'lib/potter/types.rb', line 12
def options
@options
end
|
Instance Method Details
#from(o) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/potter/types.rb', line 22
def from(o)
case o
when klass then o
when String then parse(o)
else new(o)
end
end
|
#generate(o) ⇒ Object
32
|
# File 'lib/potter/types.rb', line 32
def generate(o) = o.to_s
|
#klass ⇒ Object
19
|
# File 'lib/potter/types.rb', line 19
def klass = Object.const_get(name)
|
#name ⇒ Object
18
|
# File 'lib/potter/types.rb', line 18
def name = self.class.name.split('::').last
|
#new(o) ⇒ Object
30
|
# File 'lib/potter/types.rb', line 30
def new(o) = klass.new(o)
|
#parse(o) ⇒ Object
31
|
# File 'lib/potter/types.rb', line 31
def parse(o) = klass.parse(o)
|
#to_sym ⇒ Object
20
|
# File 'lib/potter/types.rb', line 20
def to_sym = name.underscore.to_sym
|