Class: Worlds::Components::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/worlds/components/component.rb

Direct Known Subclasses

Ticker, Travel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, commands: []) ⇒ Component

Returns a new instance of Component.



7
8
9
10
# File 'lib/worlds/components/component.rb', line 7

def initialize(entity, commands: [])
  @owner = entity
  @commands = commands
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



5
6
7
# File 'lib/worlds/components/component.rb', line 5

def commands
  @commands
end

#ownerObject (readonly)

Returns the value of attribute owner.



4
5
6
# File 'lib/worlds/components/component.rb', line 4

def owner
  @owner
end

Instance Method Details

#invokeObject



30
31
# File 'lib/worlds/components/component.rb', line 30

def invoke
end

#selectObject



20
21
22
23
24
25
26
27
28
# File 'lib/worlds/components/component.rb', line 20

def select
  return nil unless select_options.any?

  {
    type: :select,
    heading: select_heading,
    options: select_options.map(&:to_s),
  }
end

#select_headingObject



12
13
14
# File 'lib/worlds/components/component.rb', line 12

def select_heading
  "Select an option:"
end

#select_optionsObject



16
17
18
# File 'lib/worlds/components/component.rb', line 16

def select_options
  []
end

#update(ms) ⇒ Object



33
34
# File 'lib/worlds/components/component.rb', line 33

def update(ms)
end