Class: Seldom::Html

Inherits:
Object
  • Object
show all
Defined in:
lib/seldom/html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Html

Returns a new instance of Html.



5
6
7
# File 'lib/seldom/html.rb', line 5

def initialize(options={})
	@options = defaults.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/seldom/html.rb', line 3

def options
  @options
end

Instance Method Details

#bodyObject



9
10
11
12
13
14
15
# File 'lib/seldom/html.rb', line 9

def body
	"<html><body><h1>Hello, World!</h1>
	  <div>#{selector_to_html(options[:nav_selector])}</div>
	  <span>#{Faker::Lorem.sentence}<span>
	  <div>#{selector_to_html(options[:content_selector])}</div>
	</body></html>"
end

#defaultsObject



21
22
23
24
25
# File 'lib/seldom/html.rb', line 21

def defaults
	{ content_selector: '#right-content',
		nav_selector:      '#nav'
	}
end

#selector_to_html(selector, tag = 'div') ⇒ Object



17
18
19
# File 'lib/seldom/html.rb', line 17

def selector_to_html(selector, tag='div')
	"<#{tag} id=#{selector.rpartition('#').pop}>#{::Faker::Lorem.sentence}</#{tag}>"
end