Class: Lookbook::Tag
- Inherits:
-
Object
- Object
- Lookbook::Tag
- Defined in:
- lib/lookbook/tag.rb
Instance Attribute Summary collapse
-
#arg_names ⇒ Object
readonly
Returns the value of attribute arg_names.
-
#args ⇒ Object
Returns the value of attribute args.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
- #get_opt(key, fallback = nil) ⇒ Object
-
#initialize(tag_object, arg_names = nil, parser: nil, **options) ⇒ Tag
constructor
A new instance of Tag.
- #opts_str ⇒ Object
- #tag_body ⇒ Object
- #tag_name ⇒ Object
Constructor Details
#initialize(tag_object, arg_names = nil, parser: nil, **options) ⇒ Tag
Returns a new instance of Tag.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lookbook/tag.rb', line 8 def initialize(tag_object, arg_names = nil, parser: nil, **) @tag_object = tag_object @arg_names = arg_names @args = {} @opts = {} @options = @parser = parser @data = Store.new run_parser end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *method_args) ⇒ Object (protected)
100 101 102 103 104 105 106 |
# File 'lib/lookbook/tag.rb', line 100 def method_missing(name, *method_args) if name.end_with? "=" data[name.to_s.chomp("=").to_sym] = method_args.first else data[name] || args[name] end end |
Instance Attribute Details
#arg_names ⇒ Object (readonly)
Returns the value of attribute arg_names.
5 6 7 |
# File 'lib/lookbook/tag.rb', line 5 def arg_names @arg_names end |
#args ⇒ Object
Returns the value of attribute args.
6 7 8 |
# File 'lib/lookbook/tag.rb', line 6 def args @args end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/lookbook/tag.rb', line 5 def data @data end |
#opts ⇒ Object
Returns the value of attribute opts.
6 7 8 |
# File 'lib/lookbook/tag.rb', line 6 def opts @opts end |
Instance Method Details
#get_opt(key, fallback = nil) ⇒ Object
27 28 29 |
# File 'lib/lookbook/tag.rb', line 27 def get_opt(key, fallback = nil) opts[key] || fallback end |
#opts_str ⇒ Object
31 32 33 |
# File 'lib/lookbook/tag.rb', line 31 def opts_str @opts_str ||= text_tokens.size > args_count ? text_tokens.slice(args_count, text_tokens.size).join(" ") : "" end |
#tag_body ⇒ Object
23 24 25 |
# File 'lib/lookbook/tag.rb', line 23 def tag_body @tag_object.text end |
#tag_name ⇒ Object
19 20 21 |
# File 'lib/lookbook/tag.rb', line 19 def tag_name @name ||= @tag_object.tag_name.to_sym end |