Class: TileItem

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

Direct Known Subclasses

Building, Flora

Constant Summary collapse

DEFAULT_RENDER_PRIORITY =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, render_symbol:, id: object_id, render_priority: DEFAULT_RENDER_PRIORITY) ⇒ TileItem

Returns a new instance of TileItem.



7
8
9
10
11
12
# File 'lib/tile_item.rb', line 7

def initialize(obj, render_symbol:, id: object_id, render_priority: DEFAULT_RENDER_PRIORITY)
  @obj = obj
  @id = id
  @render_symbol = render_symbol
  @render_priority = render_priority
end

Instance Attribute Details

#colourObject (readonly)

Returns the value of attribute colour.



5
6
7
# File 'lib/tile_item.rb', line 5

def colour
  @colour
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/tile_item.rb', line 5

def id
  @id
end

#objObject (readonly)

Returns the value of attribute obj.



5
6
7
# File 'lib/tile_item.rb', line 5

def obj
  @obj
end

#render_priorityObject (readonly)

Returns the value of attribute render_priority.



5
6
7
# File 'lib/tile_item.rb', line 5

def render_priority
  @render_priority
end

#render_symbolObject (readonly)

Returns the value of attribute render_symbol.



5
6
7
# File 'lib/tile_item.rb', line 5

def render_symbol
  @render_symbol
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
# File 'lib/tile_item.rb', line 14

def to_h
  {
    id: id,
    type: obj.class.name.downcase,
    render_symbol: render_symbol,
    render_priority: render_priority
  }
end