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.
49 50 51 52 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 49 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.
47 48 49 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 47 def arg_name @arg_name end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
47 48 49 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 47 def keyword @keyword end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
47 48 49 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 47 def type @type end |
Instance Method Details
#has_type? ⇒ Boolean
58 59 60 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 58 def has_type? not @type.nil? end |
#keyword_without_colon ⇒ Object
54 55 56 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 54 def keyword_without_colon @keyword_without_colon ||= @keyword.sub(/:$/, '') end |
#to_s ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/xdry/parsing/parts/selectors.rb', line 62 def to_s if has_type? "#{keyword}(#{@type})#{@arg_name}" else "#{keyword}#{@arg_name}" end end |