Class: Prune::PObjects::PName
- Defined in:
- lib/prune/p_objects/p_name.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(value) ⇒ Object
Compare the value of string.
-
#eql?(value) ⇒ Boolean
Compare as a key of hash.
-
#hash ⇒ Object
Calculate hash value for PName.
-
#initialize(name) ⇒ PName
constructor
Initialize.
-
#to_s ⇒ Object
Convert content to string.
Methods inherited from Base
#indent!, #outdent!, #space, #value_to_s
Constructor Details
#initialize(name) ⇒ PName
Initialize.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/prune/p_objects/p_name.rb', line 9 def initialize(name) case name when String @name = "/" + name when Symbol @name = "/" + name.to_s else raise PNameTypeError end @name.freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/prune/p_objects/p_name.rb', line 6 def name @name end |
Instance Method Details
#==(value) ⇒ Object
Compare the value of string.
33 34 35 36 |
# File 'lib/prune/p_objects/p_name.rb', line 33 def ==(value) false if value.instance_of?(self.class) @name == value.name end |
#eql?(value) ⇒ Boolean
Compare as a key of hash.
27 28 29 30 |
# File 'lib/prune/p_objects/p_name.rb', line 27 def eql?(value) false if value.instance_of?(self.class) @name.eql?(value.name) end |
#hash ⇒ Object
Calculate hash value for PName.
22 23 24 |
# File 'lib/prune/p_objects/p_name.rb', line 22 def hash @name.hash end |
#to_s ⇒ Object
Convert content to string.
39 40 41 |
# File 'lib/prune/p_objects/p_name.rb', line 39 def to_s @name end |