Class: Element

Inherits:
Object
  • Object
show all
Defined in:
lib/lucidMachines/elements.rb

Overview

Everything is an element. (blocks, pages, and links) Blocks are the default elements.

Direct Known Subclasses

Block, Link, Page

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hiddenObject (readonly)

Returns the value of attribute hidden.



10
11
12
# File 'lib/lucidMachines/elements.rb', line 10

def hidden
  @hidden
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/lucidMachines/elements.rb', line 6

def id
  @id
end

#initialObject (readonly)

Returns the value of attribute initial.



10
11
12
# File 'lib/lucidMachines/elements.rb', line 10

def initial
  @initial
end

#pageObject (readonly)

Returns the value of attribute page.



9
10
11
# File 'lib/lucidMachines/elements.rb', line 9

def page
  @page
end

#page_idObject (readonly)

Returns the value of attribute page_id.



6
7
8
# File 'lib/lucidMachines/elements.rb', line 6

def page_id
  @page_id
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/lucidMachines/elements.rb', line 7

def text
  @text
end

#typeObject (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

Returns:

  • (Boolean)


61
62
63
# File 'lib/lucidMachines/elements.rb', line 61

def has_links?
  @link_to.size != 0 or @link_from.size != 0
end

#hideObject



26
# File 'lib/lucidMachines/elements.rb', line 26

def hide ; @hidden = true; end

#is_hidden?Boolean

Returns:

  • (Boolean)


27
# File 'lib/lucidMachines/elements.rb', line 27

def is_hidden? ; @hidden; end

#is_initial?Boolean

Returns:

  • (Boolean)


24
# File 'lib/lucidMachines/elements.rb', line 24

def is_initial? ; @initial; end

#is_state?Boolean

Returns:

  • (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


45
46
47
# File 'lib/lucidMachines/elements.rb', line 45

def link_from(element, link)
  @link_from[link] = element
end


41
42
43
# File 'lib/lucidMachines/elements.rb', line 41

def link_to(element, link)
  @link_to[link] = element
end


50
# File 'lib/lucidMachines/elements.rb', line 50

def links_from; @link_from; end


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


49
# File 'lib/lucidMachines/elements.rb', line 49

def links_to; @link_to; end


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_initialObject



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_sObject



69
70
71
# File 'lib/lucidMachines/elements.rb', line 69

def to_s
  "Element: " + @id
end