Class: XanMarkup::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/xan_markup/tag.rb

Direct Known Subclasses

ContentTag

Constant Summary collapse

QuotedString =
/"[^"]+"|'[^']+'/
QuotedFragment =
/#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/
TagArgs =
/(\w+)\s*\=\s*(#{QuotedFragment})/
CleanArgValue =
/^("|')|("|')$/

Instance Method Summary collapse

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

#argsObject



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

Returns:

  • (Boolean)


20
21
22
# File 'lib/xan_markup/tag.rb', line 20

def args?
  args.size > 0
end

#methodObject



24
25
26
# File 'lib/xan_markup/tag.rb', line 24

def method
  "markup_#{name}"
end

#nameObject



12
13
14
# File 'lib/xan_markup/tag.rb', line 12

def name
  @tag.split.first
end