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.
1794 1795 1796 1797 1798 1799 1800 1801 |
# File 'lib/puppet/pops/model/ast.rb', line 1794 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)
1792 1793 1794 |
# File 'lib/puppet/pops/model/ast.rb', line 1792 def captures_rest @captures_rest end |
#name ⇒ Object (readonly)
1789 1790 1791 |
# File 'lib/puppet/pops/model/ast.rb', line 1789 def name @name end |
#type_expr ⇒ Object (readonly)
1791 1792 1793 |
# File 'lib/puppet/pops/model/ast.rb', line 1791 def type_expr @type_expr end |
#value ⇒ Object (readonly)
1790 1791 1792 |
# File 'lib/puppet/pops/model/ast.rb', line 1790 def value @value end |
Class Method Details
._pcore_type ⇒ Object
1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 |
# File 'lib/puppet/pops/model/ast.rb', line 1740 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
1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 |
# File 'lib/puppet/pops/model/ast.rb', line 1776 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
1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 |
# File 'lib/puppet/pops/model/ast.rb', line 1765 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
1761 1762 1763 |
# File 'lib/puppet/pops/model/ast.rb', line 1761 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
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 |
# File 'lib/puppet/pops/model/ast.rb', line 1817 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
1812 1813 1814 1815 |
# File 'lib/puppet/pops/model/ast.rb', line 1812 def _pcore_contents yield(@value) unless @value.nil? yield(@type_expr) unless @type_expr.nil? end |
#_pcore_init_hash ⇒ Object
1803 1804 1805 1806 1807 1808 1809 1810 |
# File 'lib/puppet/pops/model/ast.rb', line 1803 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: ==
1830 1831 1832 1833 1834 1835 1836 |
# File 'lib/puppet/pops/model/ast.rb', line 1830 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 |