Class: Seldom::Html
- Inherits:
-
Object
- Object
- Seldom::Html
- Defined in:
- lib/seldom/html.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #body ⇒ Object
- #defaults ⇒ Object
-
#initialize(options = {}) ⇒ Html
constructor
A new instance of Html.
- #selector_to_html(selector, tag = 'div') ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Html
Returns a new instance of Html.
5 6 7 |
# File 'lib/seldom/html.rb', line 5 def initialize(={}) @options = defaults.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/seldom/html.rb', line 3 def @options end |
Instance Method Details
#body ⇒ Object
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([:nav_selector])}</div> <span>#{Faker::Lorem.sentence}<span> <div>#{selector_to_html([:content_selector])}</div> </body></html>" end |
#defaults ⇒ Object
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 |