Class: XDry::SelectorComponent
- Inherits:
-
Object
- Object
- XDry::SelectorComponent
- Defined in:
- lib/xdry/parsing/parts/selectors.rb
Instance Attribute Summary collapse
-
#arg_name ⇒ Object
readonly
Returns the value of attribute arg_name.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #has_type? ⇒ Boolean
-
#initialize(keyword, arg_name, type) ⇒ SelectorComponent
constructor
A new instance of SelectorComponent.
- #keyword_without_colon ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(keyword, arg_name, type) ⇒ SelectorComponent
Returns a new instance of SelectorComponent.
67 68 69 70 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 67 def initialize keyword, arg_name, type raise StandardError, "keyword must end with a colon: '#{keyword}'" unless keyword[-1] == ?: @keyword, @arg_name, @type = keyword, arg_name, type end |
Instance Attribute Details
#arg_name ⇒ Object (readonly)
Returns the value of attribute arg_name.
65 66 67 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 65 def arg_name @arg_name end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
65 66 67 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 65 def keyword @keyword end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
65 66 67 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 65 def type @type end |
Instance Method Details
#has_type? ⇒ Boolean
76 77 78 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 76 def has_type? not @type.nil? end |
#keyword_without_colon ⇒ Object
72 73 74 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 72 def keyword_without_colon @keyword_without_colon ||= @keyword.sub(/:$/, '') end |
#to_s ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 80 def to_s if has_type? "#{keyword}(#{@type})#{@arg_name}" else "#{keyword}#{@arg_name}" end end |