Class: Puppet::Pops::Model::Positioned
Instance Attribute Summary collapse
Attributes inherited from PopsObject
#hash
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PopsObject
#_pcore_all_contents, #_pcore_contents, #eql?, #to_s
#_pcore_all_contents, #_pcore_contents, #_pcore_type, #to_s
Constructor Details
#initialize(locator, offset, length) ⇒ Positioned
Returns a new instance of Positioned.
120
121
122
123
124
125
|
# File 'lib/puppet/pops/model/ast.rb', line 120
def initialize(locator, offset, length)
super()
@locator = locator
@offset = offset
@length = length
end
|
Instance Attribute Details
106
107
108
|
# File 'lib/puppet/pops/model/ast.rb', line 106
def length
@length
end
|
104
105
106
|
# File 'lib/puppet/pops/model/ast.rb', line 104
def locator
@locator
end
|
105
106
107
|
# File 'lib/puppet/pops/model/ast.rb', line 105
def offset
@offset
end
|
Class Method Details
._pcore_type ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/puppet/pops/model/ast.rb', line 54
def self._pcore_type
@_pcore_type ||=
Types::PObjectType
.new('Puppet::AST::Positioned',
{
'parent' => PopsObject._pcore_type,
'attributes' => {
'locator' => {
'type' => Parser::Locator::Locator19._pcore_type,
'kind' => 'reference'
},
'offset' => Types::PIntegerType::DEFAULT,
'length' => Types::PIntegerType::DEFAULT,
'file' => {
'type' => Types::PStringType::DEFAULT,
'kind' => 'derived'
},
'line' => {
'type' => Types::PIntegerType::DEFAULT,
'kind' => 'derived'
},
'pos' => {
'type' => Types::PIntegerType::DEFAULT,
'kind' => 'derived'
}
},
'equality' => []
})
end
|
.create(locator, offset, length) ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/puppet/pops/model/ast.rb', line 95
def self.create(locator, offset, length)
ta = Types::TypeAsserter
attrs = _pcore_type.attributes(true)
ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator)
ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset)
ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length)
new(locator, offset, length)
end
|
.from_asserted_hash(init_hash) ⇒ Object
88
89
90
91
92
93
|
# File 'lib/puppet/pops/model/ast.rb', line 88
def self.from_asserted_hash(init_hash)
new(
init_hash['locator'],
init_hash['offset'],
init_hash['length'])
end
|
.from_hash(init_hash) ⇒ Object
84
85
86
|
# File 'lib/puppet/pops/model/ast.rb', line 84
def self.from_hash(init_hash)
from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::Positioned initializer', _pcore_type.init_hash_type, init_hash))
end
|
Instance Method Details
#_pcore_init_hash ⇒ Object
127
128
129
130
131
132
133
|
# File 'lib/puppet/pops/model/ast.rb', line 127
def _pcore_init_hash
result = super
result['locator'] = @locator
result['offset'] = @offset
result['length'] = @length
result
end
|
108
109
110
|
# File 'lib/puppet/pops/model/ast.rb', line 108
def file
@locator.file
end
|
112
113
114
|
# File 'lib/puppet/pops/model/ast.rb', line 112
def line
@locator.line_for_offset(@offset)
end
|
116
117
118
|
# File 'lib/puppet/pops/model/ast.rb', line 116
def pos
@locator.pos_on_line(@offset)
end
|