Class: Versionub::Type::Instance
- Inherits:
-
Object
- Object
- Versionub::Type::Instance
show all
- Includes:
- Comparable
- Defined in:
- lib/versionub/type.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(type, text, data) ⇒ Instance
Returns a new instance of Instance.
30
31
32
33
34
35
|
# File 'lib/versionub/type.rb', line 30
def initialize (type, text, data)
@text = text
@type = type
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args, &block) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/versionub/type.rb', line 37
def method_missing (id, *args, &block)
if @text.respond_to?(id)
@text.send id, *args, &block
else
super
end
end
|
Class Attribute Details
.parser ⇒ Object
Returns the value of attribute parser.
58
59
60
|
# File 'lib/versionub/type.rb', line 58
def parser
@parser
end
|
Returns the value of attribute transformer.
58
59
60
|
# File 'lib/versionub/type.rb', line 58
def transformer
@transformer
end
|
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
28
29
30
|
# File 'lib/versionub/type.rb', line 28
def type
@type
end
|
Class Method Details
.parse(&block) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/versionub/type.rb', line 60
def parse (&block)
if block
@parser = Class.new(Parslet::Parser)
@parser.class_eval(&block)
end
@parser
end
|
69
70
71
72
73
74
75
76
|
# File 'lib/versionub/type.rb', line 69
def transform (&block)
if block
@transformer = Class.new(Parslet::Transform)
@transformer.class_eval(&block)
end
@transformer
end
|
Instance Method Details
#<=>(value) ⇒ Object
45
46
47
|
# File 'lib/versionub/type.rb', line 45
def <=> (value)
to_s <=> value
end
|
#to_hash ⇒ Object
49
50
51
|
# File 'lib/versionub/type.rb', line 49
def to_hash
@data.dup
end
|
#to_s ⇒ Object
Also known as:
to_str
53
54
55
|
# File 'lib/versionub/type.rb', line 53
def to_s
@text
end
|