class VueCK::Element

Public Class Methods

new(doc, type) click to toggle source
# File lib/element.rb, line 3
def initialize(doc, type)
    @node = doc.css(ELEMENTS[type])
    @type = type
    verify
end

Public Instance Methods

empty?() click to toggle source
# File lib/element.rb, line 20
def empty?
    @node.empty?
end
lang() click to toggle source
# File lib/element.rb, line 14
def lang
    lang_attribute = @node.attribute(ATTRIBUTES[:lang]).first
    return LANG_DEFALTS[@type] unless lang_attribute
    lang_attribute.value
end
render() click to toggle source
# File lib/element.rb, line 28
def render
    return text if lang == LANG_DEFALTS[@type]
    raise InvalidTemplateEngine unless Tilt[lang]
    Tilt[lang].new { text }.render
end
text() click to toggle source
# File lib/element.rb, line 24
def text
    @node.first.children.text
end
verify() click to toggle source
# File lib/element.rb, line 9
def verify
    return unless REQUIRED[@type]
    raise ComonentRenderError if @node.empty?
end