diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-07-17 00:21:36 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-07-17 08:56:48 -0300 |
commit | dd5f8bee32757a081a93899acb6189088e1d5305 (patch) | |
tree | 99ef0f0876054eaf21f022e6ac27a8d3d27042c4 /lib/highline/menu.rb | |
parent | a498560c95c80c19ec33e346f45e440612188934 (diff) | |
download | highline-dd5f8bee32757a081a93899acb6189088e1d5305.tar.gz |
It's 'nil check' hunting season
Diffstat (limited to 'lib/highline/menu.rb')
-rw-r--r-- | lib/highline/menu.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/highline/menu.rb b/lib/highline/menu.rb index 71c4f47..401cdb7 100644 --- a/lib/highline/menu.rb +++ b/lib/highline/menu.rb @@ -138,7 +138,7 @@ class HighLine def choice( name, help = nil, &action ) @items << [name, action] - @help[name.to_s.downcase] = help unless help.nil? + @help[name.to_s.downcase] = help if help update_responses # rebuild responses based on our settings end @@ -156,7 +156,7 @@ class HighLine def hidden( name, help = nil, &action ) @hidden_items << [name, action] - @help[name.to_s.downcase] = help unless help.nil? + @help[name.to_s.downcase] = help if help end # @@ -305,7 +305,7 @@ class HighLine end # Run or return it. - if not action.nil? + if action @highline = highline_context if @shell result = action.call(name, details) @@ -313,10 +313,8 @@ class HighLine result = action.call(name) end @nil_on_handled ? nil : result - elsif action.nil? - name else - nil + name end ensure # make sure the hidden items are removed, before we return @@ -349,12 +347,12 @@ class HighLine def to_s( ) case @layout when :list - '<%= if header.nil? then '' else "#{header}:\n" end %>' + + %(<%= header ? "#{header}:\n" : '' %>) + "<%= list( menu, #{@flow.inspect}, #{@list_option.inspect} ) %>" + "<%= prompt %>" when :one_line - '<%= if header.nil? then '' else "#{header}: " end %>' + + %(<%= header ? "#{header}: " : '' %>) + "<%= prompt %>" + "(<%= list( menu, #{@flow.inspect}, #{@list_option.inspect} ) %>)" + |