Class: XanMarkup::Tag
- Inherits:
-
Object
- Object
- XanMarkup::Tag
- Defined in:
- lib/xan_markup/tag.rb
Direct Known Subclasses
Constant Summary collapse
- QuotedString =
/"[^"]+"|'[^']+'/
- QuotedFragment =
/#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
- TagArgs =
/(\w+)\s*\=\s*(#{QuotedFragment})/
- CleanArgValue =
/^("|')|("|')$/
Instance Method Summary collapse
- #args ⇒ Object
- #args? ⇒ Boolean
-
#initialize(tag) ⇒ Tag
constructor
A new instance of Tag.
- #method ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(tag) ⇒ Tag
Returns a new instance of Tag.
8 9 10 |
# File 'lib/xan_markup/tag.rb', line 8 def initialize(tag) @tag = tag end |
Instance Method Details
#args ⇒ Object
16 17 18 |
# File 'lib/xan_markup/tag.rb', line 16 def args {}.tap { |args| @tag.scan(TagArgs) { |key, value| args[key.to_sym] = value.gsub(CleanArgValue, "") } } end |
#args? ⇒ Boolean
20 21 22 |
# File 'lib/xan_markup/tag.rb', line 20 def args? args.size > 0 end |
#method ⇒ Object
24 25 26 |
# File 'lib/xan_markup/tag.rb', line 24 def method "markup_#{name}" end |
#name ⇒ Object
12 13 14 |
# File 'lib/xan_markup/tag.rb', line 12 def name @tag.split.first end |