Class: HTRB::Component

Inherits:
HtmlNode
  • Object
show all
Defined in:
lib/htrb/component.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HTRB::HtmlNode

Class Method Details

.inherited(subclass) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/htrb/component.rb', line 3

def self.inherited(subclass)
  sym = ('_' + subclass.name.downcase.split('::').last + '!').to_sym

  raise TagExistsError.new sym if HtmlNode.private_method_defined? sym

  HtmlNode.send :define_method, sym do |**attributes, &contents|
    append subclass.new(**attributes, &contents)
  end
  HtmlNode.send :private, sym
end

Instance Method Details

#self_closing?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/htrb/component.rb', line 14

def self_closing?
  true
end