Class: Configurate::SettingPath
- Inherits:
-
Object
- Object
- Configurate::SettingPath
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/configurate/setting_path.rb
Overview
Class encapsulating the concept of a path to a setting
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#action? ⇒ Boolean
Whether the current path looks like an action method.
- #each ⇒ Object
-
#initialize(path = []) ⇒ SettingPath
constructor
A new instance of SettingPath.
- #initialize_copy(original) ⇒ Object
- #inspect ⇒ Object
-
#question? ⇒ Boolean
Whether the current path looks like a question method.
-
#question_action_or_setter? ⇒ Boolean
Whether the current path looks like a question or setter method.
-
#setter? ⇒ Boolean
Whether the current path looks like a setter method.
- #to_s ⇒ Object
Constructor Details
#initialize(path = []) ⇒ SettingPath
Returns a new instance of SettingPath.
9 10 11 12 |
# File 'lib/configurate/setting_path.rb', line 9 def initialize path=[] path = path.split(".") if path.is_a? String @path = path end |
Instance Method Details
#==(other) ⇒ Object
64 65 66 |
# File 'lib/configurate/setting_path.rb', line 64 def ==(other) to_s == other.to_s end |
#action? ⇒ Boolean
Whether the current path looks like an action method
32 33 34 |
# File 'lib/configurate/setting_path.rb', line 32 def action? @path.last.to_s.end_with?("!") end |
#each ⇒ Object
41 42 43 44 45 46 |
# File 'lib/configurate/setting_path.rb', line 41 def each return to_enum(:each) unless block_given? @path.each do |component| yield clean_special_characters(component) end end |
#initialize_copy(original) ⇒ Object
14 15 16 17 |
# File 'lib/configurate/setting_path.rb', line 14 def initialize_copy original super @path = @path.clone end |
#inspect ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/configurate/setting_path.rb', line 68 def inspect "<SettingPath:#{object_id.to_s(16)} "\ "path=#{self}:#{@path.object_id.to_s(16)} "\ "question=#{question?} "\ "action=#{action?} "\ "setter=#{setter?}>" end |
#question? ⇒ Boolean
Whether the current path looks like a question method
27 28 29 |
# File 'lib/configurate/setting_path.rb', line 27 def question? @path.last.to_s.end_with?("?") end |
#question_action_or_setter? ⇒ Boolean
Whether the current path looks like a question or setter method
22 23 24 |
# File 'lib/configurate/setting_path.rb', line 22 def question_action_or_setter? question? || action? || setter? end |
#setter? ⇒ Boolean
Whether the current path looks like a setter method
37 38 39 |
# File 'lib/configurate/setting_path.rb', line 37 def setter? @path.last.to_s.end_with?("=") end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/configurate/setting_path.rb', line 60 def to_s join(".") end |