Class: ObjectView::Head

Inherits:
Element
  • Object
show all
Defined in:
lib/object_view/head.rb

Instance Attribute Summary

Attributes inherited from Element

#acceptable_children, #children, #single_line, #tag

Instance Method Summary collapse

Methods inherited from Element

#<<, #add, #add_with_tag, #attr, #attributes, #css_class=, #find_element_with_tag, #id=, #is_acceptable_child?, #on_click=, #render, #render_attributes, #render_children, #style, #style=

Constructor Details

#initializeHead

Returns a new instance of Head.



11
12
13
14
15
# File 'lib/object_view/head.rb', line 11

def initialize
  super
  @tag = "head"
  self.acceptable_children = [Javascript, JavascriptFile, Stylesheet, Title, String, Link]
end

Instance Method Details

#add_stylesheet(path, id = Time.new.to_i.to_s) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/object_view/head.rb', line 17

def add_stylesheet(path, id = Time.new.to_i.to_s)
  link = self.add Stylesheet.new
  link[:href] = path
  link[:id] = id
  link[:type] = 'text/css'
  link[:media] = 'screen'
  link[:rel] = 'stylesheet'
  return link
end

#add_title(title) ⇒ Object



27
28
29
# File 'lib/object_view/head.rb', line 27

def add_title(title)
  self.add Title.new(title)
end