Class: MenuMaker::Path
- Inherits:
-
Object
- Object
- MenuMaker::Path
- Defined in:
- lib/menu_maker/path.rb
Defined Under Namespace
Modules: Converter
Constant Summary collapse
- METHODS =
%i[get post put patch delete]
- PathError =
Class.new StandardError
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(method, path) ⇒ Path
constructor
A new instance of Path.
- #to_s ⇒ Object
Constructor Details
#initialize(method, path) ⇒ Path
Returns a new instance of Path.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/menu_maker/path.rb', line 11 def initialize(method, path) method = method.to_sym.downcase unless self.class.valid_method? method fail PathError, "Method must be one of: #{METHODS.join(', ')}" end @method = method @path = path.to_s end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/menu_maker/path.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/menu_maker/path.rb', line 9 def path @path end |
Class Method Details
.valid_method?(method) ⇒ Boolean
5 6 7 |
# File 'lib/menu_maker/path.rb', line 5 def self.valid_method?(method) METHODS.include? method end |