Class: Puppet::Parser::AST::HostName

Inherits:
Leaf show all
Defined in:
lib/vendor/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

AST

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary

Attributes inherited from Leaf

#type, #value

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #scope

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods inherited from Leaf

#evaluate, #match

Methods inherited from Puppet::Parser::AST

associates_doc, #evaluate, #evaluate_match, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

#initialize(hash) ⇒ HostName

Returns a new instance of HostName.



93
94
95
96
97
98
99
100
101
102
# File 'lib/vendor/puppet/parser/ast/leaf.rb', line 93

def initialize(hash)
  super

  # Note that this is an AST::Regex, not a Regexp
  @value = @value.to_s.downcase unless @value.is_a?(Regex)
  if @value =~ /[^-\w.]/
    raise Puppet::DevError,
      "'#{@value}' is not a valid hostname"
  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

Returns:



106
107
108
109
# File 'lib/vendor/puppet/parser/ast/leaf.rb', line 106

def eql?(value)
  value = value.value if value.is_a?(HostName)
  @value.eql?(value)
end

#hashObject



111
112
113
# File 'lib/vendor/puppet/parser/ast/leaf.rb', line 111

def hash
  @value.hash
end

#to_sObject



115
116
117
# File 'lib/vendor/puppet/parser/ast/leaf.rb', line 115

def to_s
  @value.to_s
end