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.
137 138 139 |
# File 'lib/flame/path.rb', line 137 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?
146 147 148 |
# File 'lib/flame/path.rb', line 146 def ==(other) to_s == other.to_s end |
#arg? ⇒ Boolean
156 157 158 |
# File 'lib/flame/path.rb', line 156 def arg? @part.start_with? ARG_CHAR end |
#clean ⇒ Object
164 165 166 |
# File 'lib/flame/path.rb', line 164 def clean @part.delete ARG_CHAR + ARG_CHAR_OPT end |
#freeze ⇒ Object
141 142 143 144 |
# File 'lib/flame/path.rb', line 141 def freeze @part.freeze super end |
#opt_arg? ⇒ Boolean
160 161 162 |
# File 'lib/flame/path.rb', line 160 def opt_arg? @part[1] == ARG_CHAR_OPT end |
#to_s ⇒ Object
152 153 154 |
# File 'lib/flame/path.rb', line 152 def to_s @part end |