Class: SportsManager::SolutionDrawer::Mermaid::Node

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sports_manager/solution_drawer/mermaid/node.rb

Constant Summary collapse

TIME_TEMPLATE =
'%d/%m %H:%M'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixture) ⇒ Node



20
21
22
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 20

def initialize(fixture)
  @fixture = fixture
end

Instance Attribute Details

#fixtureObject (readonly)

Returns the value of attribute fixture.



10
11
12
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 10

def fixture
  @fixture
end

Class Method Details

.for(fixture) ⇒ Object



14
15
16
17
18
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 14

def self.for(fixture)
  node_class = fixture.playable? ? self : ByeNode

  node_class.new(fixture)
end

Instance Method Details

#definitionObject

Internal: my_node[This is a node]:::awesome_style



29
30
31
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 29

def definition
  "#{name}[#{description}]:::#{style_class}"
end

#depends_on?(node) ⇒ Boolean



49
50
51
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 49

def depends_on?(node)
  fixture.depends_on?(node.fixture)
end

#descriptionObject



37
38
39
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 37

def description
  "#{match_id}\\n#{title}\\n#{slot}"
end

#links?Boolean



45
46
47
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 45

def links?
  fixture.dependencies?
end

#nameObject



24
25
26
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 24

def name
  "#{category}_#{match_id}"
end

#slotObject



41
42
43
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 41

def slot
  fixture.slot.strftime(TIME_TEMPLATE)
end

#style_classObject



33
34
35
# File 'lib/sports_manager/solution_drawer/mermaid/node.rb', line 33

def style_class
  "court#{court}"
end