Class: Puppet::Parser::AST::HostName
- Inherits:
-
Leaf
- Object
- Puppet::Parser::AST
- Leaf
- Puppet::Parser::AST::HostName
- Defined in:
- lib/puppet/parser/ast/leaf.rb
Overview
Host names, either fully qualified or just the short name, or even a regex
Constant Summary
Constants inherited from Puppet::Parser::AST
Instance Attribute Summary
Attributes inherited from Leaf
Attributes inherited from Puppet::Parser::AST
#file, #line, #parent, #pos, #scope
Instance Method Summary collapse
-
#eql?(value) ⇒ Boolean
implementing eql? and hash so that when an HostName is stored in a hash it has the same hashing properties as the underlying value.
- #hash ⇒ Object
-
#initialize(value: nil, file: nil, line: nil, pos: nil) ⇒ HostName
constructor
A new instance of HostName.
Methods inherited from Leaf
Methods inherited from Puppet::Parser::AST
#evaluate, #inspect, #safeevaluate
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail
Constructor Details
#initialize(value: nil, file: nil, line: nil, pos: nil) ⇒ HostName
Returns a new instance of HostName.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet/parser/ast/leaf.rb', line 32 def initialize(value: nil, file: nil, line: nil, pos: nil) super(value: value, file: file, line: line, pos: pos) # Note that this is an AST::Regex, not a Regexp unless @value.is_a?(Regex) @value = @value.to_s.downcase if @value =~ /[^-\w.]/ raise Puppet::DevError, _("'%{value}' is not a valid hostname") % { value: @value } end end end |
Instance Method Details
#eql?(value) ⇒ Boolean
implementing eql? and hash so that when an HostName is stored in a hash it has the same hashing properties as the underlying value
46 47 48 |
# File 'lib/puppet/parser/ast/leaf.rb', line 46 def eql?(value) @value.eql?(value.is_a?(HostName) ? value.value : value) end |
#hash ⇒ Object
50 51 52 |
# File 'lib/puppet/parser/ast/leaf.rb', line 50 def hash @value.hash end |