Class: Wizardly::Wizard::Page

Inherits:
Object
  • Object
show all
Includes:
TextHelpers
Defined in:
lib/wizardly/wizard/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, id, fields) ⇒ Page

Returns a new instance of Page.



11
12
13
14
15
16
17
18
# File 'lib/wizardly/wizard/page.rb', line 11

def initialize(config, id, fields)
  @buttons = []
  @title = symbol_to_button_name(id)
  @id = id
  @description = ''
  @fields = fields 
  @config = config
end

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



9
10
11
# File 'lib/wizardly/wizard/page.rb', line 9

def buttons
  @buttons
end

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/wizardly/wizard/page.rb', line 8

def description
  @description
end

#fieldsObject

Returns the value of attribute fields.



9
10
11
# File 'lib/wizardly/wizard/page.rb', line 9

def fields
  @fields
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/wizardly/wizard/page.rb', line 8

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/wizardly/wizard/page.rb', line 8

def title
  @title
end

Instance Method Details

#buttons_to(*args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/wizardly/wizard/page.rb', line 22

def buttons_to(*args)
  buttons = @config.buttons
  @buttons = args.map do |button_id|
    raise(WizardConfigurationError, ":#{button_id} not defined as a button id in :button_to() call", caller) unless buttons.key?(button_id)
    buttons[button_id]
  end
end

#description_to(name) ⇒ Object



32
33
34
# File 'lib/wizardly/wizard/page.rb', line 32

def description_to(name)
  @description = name.strip.squeeze(' ')
end

#nameObject



20
# File 'lib/wizardly/wizard/page.rb', line 20

def name; id.to_s; end

#title_to(name) ⇒ Object



29
30
31
# File 'lib/wizardly/wizard/page.rb', line 29

def title_to(name)
  @title = name.strip.squeeze(' ')
end