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.



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

Returns:

  • (Boolean)


158
159
160
# File 'lib/flame/path.rb', line 158

def arg?
	@part.start_with? ARG_CHAR
end

#cleanObject



166
167
168
# File 'lib/flame/path.rb', line 166

def clean
	@part.delete ARG_CHAR + ARG_CHAR_OPT
end

#freezeObject



143
144
145
146
# File 'lib/flame/path.rb', line 143

def freeze
	@part.freeze
	super
end

#opt_arg?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/flame/path.rb', line 162

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

#to_sObject



154
155
156
# File 'lib/flame/path.rb', line 154

def to_s
	@part
end