Class: Factorio::Mod::Download

Inherits:
Struct
  • Object
show all
Defined in:
lib/factorio/mod/download.rb

Overview

store the entry of the download

Constant Summary collapse

TABLE_HEADER_TO_SYM =

Download page table header to attribute symbol

{
  'Version' => :version,
  'Game Version' => :game_version,
  'Download' => :uri,
  'Release Date' => :date,
  'Downloads' => :times
}.freeze
HANDLE_VALUE =
{
  version: :text.to_proc,
  game_version: :text.to_proc,
  uri: Mod.method(:get_href).to_proc,
  date: :text.to_proc,
  times: :text.to_proc >> :to_i.to_proc
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



6
7
8
# File 'lib/factorio/mod/download.rb', line 6

def date
  @date
end

#game_versionObject

Returns the value of attribute game_version

Returns:

  • (Object)

    the current value of game_version



6
7
8
# File 'lib/factorio/mod/download.rb', line 6

def game_version
  @game_version
end

#timesObject

Returns the value of attribute times

Returns:

  • (Object)

    the current value of times



6
7
8
# File 'lib/factorio/mod/download.rb', line 6

def times
  @times
end

#uriObject

Returns the value of attribute uri

Returns:

  • (Object)

    the current value of uri



6
7
8
# File 'lib/factorio/mod/download.rb', line 6

def uri
  @uri
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



6
7
8
# File 'lib/factorio/mod/download.rb', line 6

def version
  @version
end

Instance Method Details

#set(name, value) ⇒ Object

set value by table header



25
26
27
28
# File 'lib/factorio/mod/download.rb', line 25

def set(name, value)
  sym = TABLE_HEADER_TO_SYM[name]
  tap { |a| a[sym] = HANDLE_VALUE[sym].call value }
end