Class: Flame::Path::PathPart

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


156
157
158
# File 'lib/flame/path.rb', line 156

def arg?
	@part.start_with? ARG_CHAR
end

#cleanObject



164
165
166
# File 'lib/flame/path.rb', line 164

def clean
	@part.delete ARG_CHAR + ARG_CHAR_OPT
end

#freezeObject



141
142
143
144
# File 'lib/flame/path.rb', line 141

def freeze
	@part.freeze
	super
end

#opt_arg?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/flame/path.rb', line 160

def opt_arg?
	@part[1] == ARG_CHAR_OPT
end

#to_sObject



152
153
154
# File 'lib/flame/path.rb', line 152

def to_s
	@part
end