Class: Flame::Path::PathPart
- Inherits:
-
Object
- Object
- Flame::Path::PathPart
- Extended by:
- Forwardable
- Defined in:
- lib/flame/path.rb
Overview
Class for one part of Path
Constant Summary collapse
- ARG_CHAR =
':'
- ARG_CHAR_OPT =
'?'
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #arg? ⇒ Boolean
- #clean ⇒ Object
- #freeze ⇒ Object
-
#initialize(part, arg: false) ⇒ PathPart
constructor
A new instance of PathPart.
- #opt_arg? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(part, arg: false) ⇒ PathPart
Returns a new instance of PathPart.
139 140 141 |
# File 'lib/flame/path.rb', line 139 def initialize(part, arg: false) @part = "#{ARG_CHAR if arg}#{ARG_CHAR_OPT if arg == :opt}#{part}" end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
148 149 150 |
# File 'lib/flame/path.rb', line 148 def ==(other) to_s == other.to_s end |
#arg? ⇒ Boolean
158 159 160 |
# File 'lib/flame/path.rb', line 158 def arg? @part.start_with? ARG_CHAR end |
#clean ⇒ Object
166 167 168 |
# File 'lib/flame/path.rb', line 166 def clean @part.delete ARG_CHAR + ARG_CHAR_OPT end |
#freeze ⇒ Object
143 144 145 146 |
# File 'lib/flame/path.rb', line 143 def freeze @part.freeze super end |
#opt_arg? ⇒ Boolean
162 163 164 |
# File 'lib/flame/path.rb', line 162 def opt_arg? @part[1] == ARG_CHAR_OPT end |
#to_s ⇒ Object
154 155 156 |
# File 'lib/flame/path.rb', line 154 def to_s @part end |