Class: Gm::Notepad::Parameters::TableLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/gm/notepad/parameters/table_lookup.rb

Overview

Responsible for teasing apart the table logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, roll_dice: false) ⇒ TableLookup

Returns a new instance of TableLookup.



7
8
9
10
11
12
13
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 7

def initialize(text:, roll_dice: false)
  @text = text.strip
  @role_dice = false
  @parameters = {}
  extract_parameters!
  roll_them_bones! if roll_dice
end

Instance Attribute Details

#cellObject

Returns the value of attribute cell.



15
16
17
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 15

def cell
  @cell
end

#grepObject

Returns the value of attribute grep.



15
16
17
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 15

def grep
  @grep
end

#indexObject

Returns the value of attribute index.



15
16
17
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 15

def index
  @index
end

#table_nameObject

Returns the value of attribute table_name.



15
16
17
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 15

def table_name
  @table_name
end

Instance Method Details

#parametersObject



17
18
19
20
21
22
23
# File 'lib/gm/notepad/parameters/table_lookup.rb', line 17

def parameters
  parameters = { table_name: table_name }
  parameters[:grep] = grep if grep
  parameters[:index] = index if index
  parameters[:cell] = cell if cell
  parameters
end