Class: Metamagic::Tag

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

Direct Known Subclasses

CustomTag, MetaTag, PropertyTag, TitleTag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, key, value) ⇒ Tag

Returns a new instance of Tag.



5
6
7
# File 'lib/metamagic/tag.rb', line 5

def initialize(context, key, value)
  @context, @key, @value = context, key, value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



25
26
27
# File 'lib/metamagic/tag.rb', line 25

def method_missing(*args)
  context.send(*args)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



3
4
5
# File 'lib/metamagic/tag.rb', line 3

def context
  @context
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/metamagic/tag.rb', line 3

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/metamagic/tag.rb', line 3

def value
  @value
end

Instance Method Details

#<=>(other) ⇒ Object



21
22
23
# File 'lib/metamagic/tag.rb', line 21

def <=>(other)
  [sort_order, self.class.name] <=> [other.sort_order, other.class.name]
end

#==(other) ⇒ Object



17
18
19
# File 'lib/metamagic/tag.rb', line 17

def ==(other)
  self.class == other.class && self.key == other.key
end

#sort_orderObject



13
14
15
# File 'lib/metamagic/tag.rb', line 13

def sort_order
  1000
end

#to_htmlObject



9
10
11
# File 'lib/metamagic/tag.rb', line 9

def to_html
  raise "#{self.class.name}#to_html must be overridden to render tag"
end