Class: Element
- Inherits:
-
Object
- Object
- Element
- Defined in:
- lib/lucidMachines/elements.rb
Overview
Everything is an element. (blocks, pages, and links) Blocks are the default elements.
Instance Attribute Summary collapse
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#initial ⇒ Object
readonly
Returns the value of attribute initial.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_id ⇒ Object
readonly
Returns the value of attribute page_id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #has_links? ⇒ Boolean
- #hide ⇒ Object
-
#initialize(entry) ⇒ Element
constructor
Elements are created from an CSV entry.
- #is_hidden? ⇒ Boolean
- #is_initial? ⇒ Boolean
- #is_state? ⇒ Boolean
- #link_from(element, link) ⇒ Object
- #link_to(element, link) ⇒ Object
- #links_from ⇒ Object
- #links_from_type(type) ⇒ Object
- #links_to ⇒ Object
- #links_to_type(type) ⇒ Object
- #set_initial ⇒ Object
- #set_page(p) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(entry) ⇒ Element
Elements are created from an CSV entry
13 14 15 16 17 18 19 20 21 |
# File 'lib/lucidMachines/elements.rb', line 13 def initialize(entry) @id = entry["Id"] @type = entry["Name"] @text = entry["Text Area 1"] @page_id = entry["Page ID"] @link_to = {} @link_from = {} @initial = false end |
Instance Attribute Details
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
10 11 12 |
# File 'lib/lucidMachines/elements.rb', line 10 def hidden @hidden end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/lucidMachines/elements.rb', line 6 def id @id end |
#initial ⇒ Object (readonly)
Returns the value of attribute initial.
10 11 12 |
# File 'lib/lucidMachines/elements.rb', line 10 def initial @initial end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
9 10 11 |
# File 'lib/lucidMachines/elements.rb', line 9 def page @page end |
#page_id ⇒ Object (readonly)
Returns the value of attribute page_id.
6 7 8 |
# File 'lib/lucidMachines/elements.rb', line 6 def page_id @page_id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/lucidMachines/elements.rb', line 7 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/lucidMachines/elements.rb', line 7 def type @type end |
Instance Method Details
#has_links? ⇒ Boolean
61 62 63 |
# File 'lib/lucidMachines/elements.rb', line 61 def has_links? @link_to.size != 0 or @link_from.size != 0 end |
#hide ⇒ Object
26 |
# File 'lib/lucidMachines/elements.rb', line 26 def hide ; @hidden = true; end |
#is_hidden? ⇒ Boolean
27 |
# File 'lib/lucidMachines/elements.rb', line 27 def is_hidden? ; @hidden; end |
#is_initial? ⇒ Boolean
24 |
# File 'lib/lucidMachines/elements.rb', line 24 def is_initial? ; @initial; end |
#is_state? ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lucidMachines/elements.rb', line 29 def is_state? # not is_hidden? and has_links? and not text.nil? return false if is_hidden? or not has_links? if text.nil? type.eql? "transition" else true end end |
#link_from(element, link) ⇒ Object
45 46 47 |
# File 'lib/lucidMachines/elements.rb', line 45 def link_from(element, link) @link_from[link] = element end |
#link_to(element, link) ⇒ Object
41 42 43 |
# File 'lib/lucidMachines/elements.rb', line 41 def link_to(element, link) @link_to[link] = element end |
#links_from ⇒ Object
50 |
# File 'lib/lucidMachines/elements.rb', line 50 def links_from; @link_from; end |
#links_from_type(type) ⇒ Object
56 57 58 |
# File 'lib/lucidMachines/elements.rb', line 56 def links_from_type(type) @link_from.each_value.select{ |b| b.type.eql? type } end |
#links_to ⇒ Object
49 |
# File 'lib/lucidMachines/elements.rb', line 49 def links_to; @link_to; end |
#links_to_type(type) ⇒ Object
52 53 54 |
# File 'lib/lucidMachines/elements.rb', line 52 def links_to_type(type) @link_to.each_value.select{ |b| b.type.eql? type } end |
#set_initial ⇒ Object
23 |
# File 'lib/lucidMachines/elements.rb', line 23 def set_initial ; @initial = true; end |
#set_page(p) ⇒ Object
65 66 67 |
# File 'lib/lucidMachines/elements.rb', line 65 def set_page(p) @page = p end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/lucidMachines/elements.rb', line 69 def to_s "Element: " + @id end |