Class: AMA::Entity::Mapper::Path::Segment
- Inherits:
-
Object
- Object
- AMA::Entity::Mapper::Path::Segment
- Defined in:
- lib/ama-entity-mapper/path/segment.rb
Overview
Well, that's quite self-explanatory. Path consists of segments, and here's one.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, prefix = nil, suffix = nil) ⇒ Segment
constructor
A new instance of Segment.
- #to_s ⇒ Object
Constructor Details
#initialize(name, prefix = nil, suffix = nil) ⇒ Segment
Returns a new instance of Segment.
14 15 16 17 18 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 14 def initialize(name, prefix = nil, suffix = nil) @name = name @prefix = prefix @suffix = suffix end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 10 def name @name end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
11 12 13 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 11 def prefix @prefix end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
12 13 14 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 12 def suffix @suffix end |
Class Method Details
.attribute(name) ⇒ Object
39 40 41 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 39 def attribute(name) new(name, '.') end |
.index(name) ⇒ Object
43 44 45 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 43 def index(name) new(name, '[', ']') end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 34 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 28 def eql?(other) return false unless other.is_a?(self.class) @name == other.name && @prefix == other.prefix && @suffix == other.suffix end |
#hash ⇒ Object
24 25 26 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 24 def hash @name.hash ^ @prefix.hash ^ @suffix.hash end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/ama-entity-mapper/path/segment.rb', line 20 def to_s "#{@prefix}#{@name}#{@suffix}" end |