Class: Alister::HTML::Element
- Inherits:
-
Object
- Object
- Alister::HTML::Element
- Defined in:
- lib/html/element.rb
Overview
Note:
this isn’t meant to be used directly, you need multiple of these to create a full <p>foo</p>
Create a part of an element like puzzle pieces
Constant Summary collapse
- TAG_START =
Creates “<tag” on #to_s
:tag_start- TAG_END =
Creates “</tag>n” on #to_s
:tag_end- VALUE_BLOCK =
Creates “>n” on #to_s
:value_block- VALUE_LIT =
Creates “>value” on #to_s
:value_lit- VALUE_NIL =
Creates “/>n” on #to_s
:value_nil- DOCTYPE =
Creates “<!DOCTYPE html>\n” on #to_s
:doctype- ATTR =
Creates “ key="value"” on #to_s
:attributes
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(id:, value: nil) ⇒ Element
constructor
A new instance of Element.
- #to_s ⇒ String
Constructor Details
#initialize(id:, value: nil) ⇒ Element
Returns a new instance of Element.
32 33 34 35 36 |
# File 'lib/html/element.rb', line 32 def initialize(id:, value: nil) @id = id @value = value @value = 'p' if [TAG_START, TAG_END].include?(id) && value == 'para' end |
Instance Attribute Details
#id ⇒ Symbol
Note:
Look up Alister::HTML::Element Constants for the value of id
25 26 27 |
# File 'lib/html/element.rb', line 25 def id @id end |
#value ⇒ String, void
28 29 30 |
# File 'lib/html/element.rb', line 28 def value @value end |
Instance Method Details
#to_s ⇒ String
Creates a string from part of an element Depends on #id on what it will return Look for Alister::HTML::Element Constants for returns
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/html/element.rb', line 42 def to_s case @id when TAG_START tag_start when TAG_END tag_end when VALUE_BLOCK value_block when VALUE_LIT value_lit when VALUE_NIL value_nil when ATTR attribute end end |