Class: RailsWizard::Config::Prompt
- Inherits:
-
Object
- Object
- RailsWizard::Config::Prompt
show all
- Defined in:
- lib/rails_wizard/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(details) ⇒ Prompt
Returns a new instance of Prompt.
30
31
32
33
|
# File 'lib/rails_wizard/config.rb', line 30
def initialize(details)
@details = details
@prompt = details['prompt']
end
|
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
29
30
31
|
# File 'lib/rails_wizard/config.rb', line 29
def details
@details
end
|
#prompt ⇒ Object
Returns the value of attribute prompt.
29
30
31
|
# File 'lib/rails_wizard/config.rb', line 29
def prompt
@prompt
end
|
Instance Method Details
#compile ⇒ Object
35
36
37
|
# File 'lib/rails_wizard/config.rb', line 35
def compile
"#{question} if #{conditions}"
end
|
#conditions ⇒ Object
43
44
45
|
# File 'lib/rails_wizard/config.rb', line 43
def conditions
[config_conditions, scroll_conditions].join(' && ')
end
|
#config_conditions ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/rails_wizard/config.rb', line 47
def config_conditions
if details['if']
"config['#{details['if']}']"
elsif details['unless']
"!config['#{details['unless']}']"
else
'true'
end
end
|
#question ⇒ Object
39
40
41
|
# File 'lib/rails_wizard/config.rb', line 39
def question
"ask_wizard(#{prompt.inspect})"
end
|
57
58
59
60
61
62
63
64
65
|
# File 'lib/rails_wizard/config.rb', line 57
def scroll_conditions
if details['if_scroll']
"scroll?('#{details['if_scroll']}')"
elsif details['unless_scroll']
"!scroll?('#{details['unless_scroll']}')"
else
'true'
end
end
|