Class: Puppet::Pops::Model::Parameter
- Inherits:
-
Positioned
- Object
- PopsObject
- Positioned
- Puppet::Pops::Model::Parameter
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #captures_rest ⇒ Object readonly
- #name ⇒ Object readonly
- #type_expr ⇒ Object readonly
- #value ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents {|@value| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) ⇒ Parameter
constructor
A new instance of Parameter.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) ⇒ Parameter
Returns a new instance of Parameter.
1841 1842 1843 1844 1845 1846 1847 1848 |
# File 'lib/puppet/pops/model/ast.rb', line 1841 def initialize(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) super(locator, offset, length) @hash = @hash ^ name.hash ^ value.hash ^ type_expr.hash ^ captures_rest.hash @name = name @value = value @type_expr = type_expr @captures_rest = captures_rest end |
Instance Attribute Details
#captures_rest ⇒ Object (readonly)
1839 1840 1841 |
# File 'lib/puppet/pops/model/ast.rb', line 1839 def captures_rest @captures_rest end |
#name ⇒ Object (readonly)
1836 1837 1838 |
# File 'lib/puppet/pops/model/ast.rb', line 1836 def name @name end |
#type_expr ⇒ Object (readonly)
1838 1839 1840 |
# File 'lib/puppet/pops/model/ast.rb', line 1838 def type_expr @type_expr end |
#value ⇒ Object (readonly)
1837 1838 1839 |
# File 'lib/puppet/pops/model/ast.rb', line 1837 def value @value end |
Class Method Details
._pcore_type ⇒ Object
1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 |
# File 'lib/puppet/pops/model/ast.rb', line 1785 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::Parameter', { 'parent' => Positioned._pcore_type, 'attributes' => { 'name' => Types::PStringType::DEFAULT, 'value' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'type_expr' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'captures_rest' => { 'type' => Types::POptionalType.new(Types::PBooleanType::DEFAULT), 'value' => nil } } }) end |
.create(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) ⇒ Object
1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 |
# File 'lib/puppet/pops/model/ast.rb', line 1823 def self.create(locator, offset, length, name, value = nil, type_expr = nil, captures_rest = nil) 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) ta.assert_instance_of('Puppet::AST::Parameter[name]', attrs['name'].type, name) ta.assert_instance_of('Puppet::AST::Parameter[value]', attrs['value'].type, value) ta.assert_instance_of('Puppet::AST::Parameter[type_expr]', attrs['type_expr'].type, type_expr) ta.assert_instance_of('Puppet::AST::Parameter[captures_rest]', attrs['captures_rest'].type, captures_rest) new(locator, offset, length, name, value, type_expr, captures_rest) end |
.from_asserted_hash(init_hash) ⇒ Object
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 |
# File 'lib/puppet/pops/model/ast.rb', line 1812 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['name'], init_hash['value'], init_hash['type_expr'], init_hash['captures_rest']) end |
.from_hash(init_hash) ⇒ Object
1808 1809 1810 |
# File 'lib/puppet/pops/model/ast.rb', line 1808 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::Parameter initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 |
# File 'lib/puppet/pops/model/ast.rb', line 1864 def _pcore_all_contents(path, &block) path << self unless @value.nil? block.call(@value, path) @value._pcore_all_contents(path, &block) end unless @type_expr.nil? block.call(@type_expr, path) @type_expr._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@value| ... } ⇒ Object
1859 1860 1861 1862 |
# File 'lib/puppet/pops/model/ast.rb', line 1859 def _pcore_contents yield(@value) unless @value.nil? yield(@type_expr) unless @type_expr.nil? end |
#_pcore_init_hash ⇒ Object
1850 1851 1852 1853 1854 1855 1856 1857 |
# File 'lib/puppet/pops/model/ast.rb', line 1850 def _pcore_init_hash result = super result['name'] = @name result['value'] = @value unless @value == nil result['type_expr'] = @type_expr unless @type_expr == nil result['captures_rest'] = @captures_rest unless @captures_rest == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
1877 1878 1879 1880 1881 1882 1883 |
# File 'lib/puppet/pops/model/ast.rb', line 1877 def eql?(o) super && @name.eql?(o.name) && @value.eql?(o.value) && @type_expr.eql?(o.type_expr) && @captures_rest.eql?(o.captures_rest) end |