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.
115
116
117
118
119
120
|
# File 'lib/puppet/pops/model/ast.rb', line 115
def initialize(locator, offset, length)
super()
@locator = locator
@offset = offset
@length = length
end
|
Instance Attribute Details
101
102
103
|
# File 'lib/puppet/pops/model/ast.rb', line 101
def length
@length
end
|
99
100
101
|
# File 'lib/puppet/pops/model/ast.rb', line 99
def locator
@locator
end
|
100
101
102
|
# File 'lib/puppet/pops/model/ast.rb', line 100
def offset
@offset
end
|
Class Method Details
._pcore_type ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/puppet/pops/model/ast.rb', line 52
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
90
91
92
93
94
95
96
97
|
# File 'lib/puppet/pops/model/ast.rb', line 90
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
83
84
85
86
87
88
|
# File 'lib/puppet/pops/model/ast.rb', line 83
def self.from_asserted_hash(init_hash)
new(
init_hash['locator'],
init_hash['offset'],
init_hash['length'])
end
|
.from_hash(init_hash) ⇒ Object
79
80
81
|
# File 'lib/puppet/pops/model/ast.rb', line 79
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
122
123
124
125
126
127
128
|
# File 'lib/puppet/pops/model/ast.rb', line 122
def _pcore_init_hash
result = super
result['locator'] = @locator
result['offset'] = @offset
result['length'] = @length
result
end
|
103
104
105
|
# File 'lib/puppet/pops/model/ast.rb', line 103
def file
@locator.file
end
|
107
108
109
|
# File 'lib/puppet/pops/model/ast.rb', line 107
def line
@locator.line_for_offset(@offset)
end
|
111
112
113
|
# File 'lib/puppet/pops/model/ast.rb', line 111
def pos
@locator.pos_on_line(@offset)
end
|