tty-prompt 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +17 -0
  4. data/Gemfile +2 -3
  5. data/README.md +140 -12
  6. data/appveyor.yml +1 -0
  7. data/examples/enum_select_disabled.rb +16 -0
  8. data/examples/{enum_paged.rb → enum_select_paged.rb} +0 -0
  9. data/examples/enum_select_wrapped.rb +15 -0
  10. data/examples/multi_select_disabled.rb +17 -0
  11. data/examples/multi_select_wrapped.rb +15 -0
  12. data/examples/select.rb +3 -1
  13. data/examples/select_disabled.rb +18 -0
  14. data/examples/{enum.rb → select_enum.rb} +0 -0
  15. data/examples/select_filtered.rb +3 -1
  16. data/examples/select_paginated.rb +3 -1
  17. data/examples/select_wrapped.rb +15 -0
  18. data/lib/tty/prompt.rb +1 -0
  19. data/lib/tty/prompt/answers_collector.rb +1 -0
  20. data/lib/tty/prompt/choice.rb +67 -25
  21. data/lib/tty/prompt/choices.rb +1 -0
  22. data/lib/tty/prompt/confirm_question.rb +3 -4
  23. data/lib/tty/prompt/converter_dsl.rb +1 -0
  24. data/lib/tty/prompt/converter_registry.rb +1 -0
  25. data/lib/tty/prompt/converters.rb +1 -0
  26. data/lib/tty/prompt/distance.rb +1 -0
  27. data/lib/tty/prompt/enum_list.rb +58 -17
  28. data/lib/tty/prompt/enum_paginator.rb +1 -0
  29. data/lib/tty/prompt/evaluator.rb +1 -0
  30. data/lib/tty/prompt/expander.rb +14 -14
  31. data/lib/tty/prompt/keypress.rb +1 -1
  32. data/lib/tty/prompt/list.rb +78 -39
  33. data/lib/tty/prompt/mask_question.rb +5 -4
  34. data/lib/tty/prompt/multi_list.rb +13 -3
  35. data/lib/tty/prompt/multiline.rb +6 -5
  36. data/lib/tty/prompt/paginator.rb +1 -0
  37. data/lib/tty/prompt/question.rb +10 -9
  38. data/lib/tty/prompt/question/checks.rb +1 -0
  39. data/lib/tty/prompt/question/modifier.rb +1 -0
  40. data/lib/tty/prompt/question/validation.rb +1 -0
  41. data/lib/tty/prompt/result.rb +1 -0
  42. data/lib/tty/prompt/slider.rb +3 -2
  43. data/lib/tty/prompt/statement.rb +1 -0
  44. data/lib/tty/prompt/suggestion.rb +4 -6
  45. data/lib/tty/prompt/symbols.rb +2 -1
  46. data/lib/tty/prompt/timeout.rb +16 -11
  47. data/lib/tty/prompt/utils.rb +1 -0
  48. data/lib/tty/prompt/version.rb +1 -1
  49. data/lib/tty/test_prompt.rb +1 -0
  50. metadata +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 90f71ba30290379f0e69eb5ff8affb0276d15507
4
- data.tar.gz: c16aecac4d1203614dacf82287c2ec7f6f4e8ffd
2
+ SHA256:
3
+ metadata.gz: 6dde0a99b670047f5cd262c047451d003dfc47ed8179bcd8b4f5e826612baeb8
4
+ data.tar.gz: 2b9dca2f4d4790a157f30457dd1e5d4c1696aaaf29327624ee886342e67acec5
5
5
  SHA512:
6
- metadata.gz: bfc62f62785695cf6efa2987acce5bbba00dcfcfe05c33a7641517178017f5a12ec1b600a20e650cf133babea6f6cfe2de8e926f5f9c55d7213b8fb0b0e87d05
7
- data.tar.gz: c1e1333370fb6bed3d61fc684788be691698598399358ea5d7354954d9e05604a62871affa17c202e94d6d51d2afe2923f698661d2fb1496b1b06ab966c9f916
6
+ metadata.gz: d7504991bca7514addf3b72afdd2fcbf3e811528d06e9dede50edc7c80398a1cc486e6662162094afe5eb06657df14fa06082d59b4e587ed2afeac66af7f1e6b
7
+ data.tar.gz: d6ab20ddeae00214b47428e6c5f9a65aa756d08466e5bf68e84acf6f58cba975d81ad4f99ffa687190694e7bd158e5a82c9af9c6bb74c802344aeb6f2badf628
@@ -11,6 +11,7 @@ rvm:
11
11
  - 2.2.8
12
12
  - 2.3.6
13
13
  - 2.4.3
14
+ - 2.5.0
14
15
  - ruby-head
15
16
  - jruby-9000
16
17
  - jruby-9.1.1.0
@@ -1,5 +1,21 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.16.0] - 2018-03-11
4
+
5
+ ### Added
6
+ * Add :disabled key to Choice
7
+ * Add ability to disable choices in #select, #multi_selct & #enum_select prompts
8
+ * Add #frozen_string_literal to all files
9
+
10
+ ### Changed
11
+ * Change Choice#from to allow parsing different data strucutures
12
+ * Change all classes to prevent strings mutations
13
+ * Change Timeout to cleanly terminate keypress input without raising errors
14
+
15
+ ### Fixed
16
+ * Fix #select, #enum_select & #multi_select navigation to work correctly with items longer than terminal screen width
17
+ * Fix timeout on Ruby 2.5 and stop raising Timeout::Error
18
+
3
19
  ## [v0.15.0] - 2018-02-08
4
20
 
5
21
  ### Added
@@ -245,6 +261,7 @@
245
261
 
246
262
  * Initial implementation and release
247
263
 
264
+ [v0.16.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.15.0...v0.16.0
248
265
  [v0.15.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.14.0...v0.15.0
249
266
  [v0.14.0]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.2...v0.14.0
250
267
  [v0.13.2]: https://github.com/piotrmurach/tty-prompt/compare/v0.13.1...v0.13.2
data/Gemfile CHANGED
@@ -7,9 +7,8 @@ gemspec
7
7
 
8
8
  group :test do
9
9
  gem 'benchmark-ips', '~> 2.7.2'
10
- gem 'simplecov', '~> 0.10.0'
11
- gem 'coveralls', '~> 0.8.2'
12
- gem 'term-ansicolor', '=1.3.2'
10
+ gem 'simplecov', '~> 0.14.1'
11
+ gem 'coveralls', '~> 0.8.21'
13
12
  end
14
13
 
15
14
  group :tools do
data/README.md CHANGED
@@ -68,16 +68,20 @@ Or install it yourself as:
68
68
  * [2.1.7 required](#217-required)
69
69
  * [2.1.8 validate](#218-validate)
70
70
  * [2.2 keypress](#22-keypress)
71
- * [2.2.1 timeout](#221-timeout)
71
+ * [2.2.1 :timeout](#221-timeout)
72
72
  * [2.3 multiline](#23-multiline)
73
73
  * [2.4 mask](#24-mask)
74
74
  * [2.5 yes?/no?](#25-yesno)
75
75
  * [2.6 menu](#26-menu)
76
- * [2.6.1 select](#261-select)
77
- * [2.6.2 multi_select](#262-multi_select)
78
- * [2.6.2.1 echo](#2621-echo)
79
- * [2.6.2.2 filter](#2622-filter)
80
- * [2.6.3 enum_select](#263-enum_select)
76
+ * [2.6.1 choices](#261-choices)
77
+ * [2.6.1.1 :disabled](#2611-disabled)
78
+ * [2.6.2 select](#262-select)
79
+ * [2.6.2.1 :disabled](#2621-disabled)
80
+ * [2.6.2.2 :filter](#2622-filter)
81
+ * [2.6.3 multi_select](#263-multi_select)
82
+ * [2.6.3.1 :echo](#2631-echo)
83
+ * [2.6.3.2 :filter](#2632-filter)
84
+ * [2.6.4 enum_select](#264-enum_select)
81
85
  * [2.7 expand](#27-expand)
82
86
  * [2.8 collect](#28-collect)
83
87
  * [2.9 suggest](#29-suggest)
@@ -510,7 +514,65 @@ Similarly to `yes?` method, you can supply the same options to customize the que
510
514
 
511
515
  ### 2.6 menu
512
516
 
513
- ### 2.6.1 select
517
+ ### 2.6.1 choices
518
+
519
+ There are many ways in which you can add menu choices. The simplest way is to create an array of values:
520
+
521
+ ```ruby
522
+ choices = %w(small medium large)
523
+ ```
524
+
525
+ By default the choice name is also the value the prompt will return when selected. To provide custom values, you can provide a hash with keys as choice names and their respective values:
526
+
527
+ ```ruby
528
+ choices = {small: 1, medium: 2, large: 3}
529
+ ```
530
+
531
+ Finally, you can define an array of choices where each choice is a hash value with `:name` & `:value` keys which can include other options for customising indvidual choices:
532
+
533
+ ```ruby
534
+ choices = [
535
+ {name: 'small', value: 1},
536
+ {name: 'medium', value: 2, disabled: '(out of stock)'},
537
+ {name: 'large', value: 3}
538
+ ]
539
+ ```
540
+
541
+ You can specify `:key` as an additional option which will be used as short name for selecting the choice via keyboard key press.
542
+
543
+ Another way to create menu with choices is using the DSL and the `choice` method. For example, the previous array of choices with hash values can be translated as:
544
+
545
+ ```ruby
546
+ prompt.select('What size?') do |menu|
547
+ menu.choice name: 'small', value: 1
548
+ menu.choice name: 'medium', value: 2, disabled: '(out of stock)'
549
+ menu.choice name: 'large', value: 3
550
+ end
551
+ ```
552
+
553
+ or in a more compact way:
554
+
555
+ ```ruby
556
+ prompt.select('What size?') do |menu|
557
+ menu.choice 'small', 1
558
+ menu.choice 'medium', 2, disabled: '(out of stock)'
559
+ menu.choice 'large', 3
560
+ end
561
+ ```
562
+
563
+ #### 2.6.1.1 `:disabled`
564
+
565
+ The `:disabled` key indicates to display a choice as currently unavailable to select. Disabled choices are displayed with a cross `✘` character next to them. If the choice is disabled, it cannot be selected. The value for the `:disabled` is used next to the choice to provide reason for excluding it from the selection menu. For example:
566
+
567
+ ```ruby
568
+ choices = [
569
+ {name: 'small', value: 1},
570
+ {name: 'medium', value: 2, disabled: '(out of stock)'}
571
+ {name: 'large', value: 3}
572
+ ]
573
+ ```
574
+
575
+ ### 2.6.2 select
514
576
 
515
577
  For asking questions involving list of options use `select` method by passing the question and possible choices:
516
578
 
@@ -641,7 +703,73 @@ prompt.select("Choose your letter?") do |menu|
641
703
  end
642
704
  ```
643
705
 
644
- ### 2.6.2 multi_select
706
+ #### 2.6.2.1 `:disabled`
707
+
708
+ To disable menu choice, use the `:disabled` key with a value that explains the reason for the choice being unavailable. For example, out of all warriors, the Goro is currently injured:
709
+
710
+ ```ruby
711
+ warriors = [
712
+ 'Scorpion',
713
+ 'Kano',
714
+ { name: 'Goro', disabled: '(injury)' },
715
+ 'Jax',
716
+ 'Kitana',
717
+ 'Raiden'
718
+ ]
719
+ ```
720
+
721
+ The disabled choice will be displaed with a cross `✘` character next to it and followed by an explanation:
722
+
723
+ ```ruby
724
+ prompt.select('Choose your destiny?', warriors)
725
+ # =>
726
+ # Choose your destiny? (Use arrow keys, press Enter to select)
727
+ # ‣ Scorpion
728
+ # Kano
729
+ # ✘ Goro (injury)
730
+ # Jax
731
+ # Kitana
732
+ # Raiden
733
+ ```
734
+
735
+ #### 2.6.2.2 `:filter`
736
+
737
+ To activate dynamic list searching on letter/number key presses use `:filter` option:
738
+
739
+ ```ruby
740
+ warriors = %w(Scorpion Kano Jax Kitana Raiden)
741
+ prompt.select('Choose your destiny?', warriors, filter: true)
742
+ # =>
743
+ # Choose your destiny? (Use arrow keys, press Enter to select, and letter keys to filter)
744
+ # ‣ Scorpion
745
+ # Kano
746
+ # Jax
747
+ # Kitana
748
+ # Raiden
749
+ ```
750
+
751
+ After the user presses "k":
752
+
753
+ ```ruby
754
+ # =>
755
+ # Choose your destiny? (Filter: "k")
756
+ # ‣ Kano
757
+ # Kitana
758
+ ```
759
+
760
+ After the user presse "ka":
761
+
762
+ ```ruby
763
+ # =>
764
+ # Choose your destiny? (Filter: "ka")
765
+ # ‣ Kano
766
+ ```
767
+
768
+ Filter characters can be deleted partially or entirely via, respectively, Backspace and Canc.
769
+
770
+ If the user changes or deletes a filter, the choices previously selected remain selected.
771
+
772
+ ### 2.6.3 multi_select
645
773
 
646
774
  For asking questions involving multiple selection list use `multi_select` method by passing the question and possible choices:
647
775
 
@@ -762,7 +890,7 @@ prompt.multi_select("Choose your letter?", letters, per_page: 4)
762
890
  # (Move up or down to reveal more choices)
763
891
  ```
764
892
 
765
- ### 2.6.2.1 echo
893
+ ### 2.6.3.1 `:echo`
766
894
 
767
895
  To control whether the selected items are shown on the question
768
896
  header use the :echo option:
@@ -779,7 +907,7 @@ prompt.multi_select("Select drinks?", choices, echo: false)
779
907
  # ‣ ⬢ 5) bourbon
780
908
  ```
781
909
 
782
- ### 2.6.2.2 filter
910
+ ### 2.6.3.2 `:filter`
783
911
 
784
912
  To activate dynamic list filtering on letter/number typing, use the :filter option:
785
913
 
@@ -797,7 +925,7 @@ prompt.multi_select("Select drinks?", choices, filter: true)
797
925
 
798
926
  After the user presses "w":
799
927
 
800
- ```
928
+ ```ruby
801
929
  # Select drinks? (Filter: "w")
802
930
  # ‣ ⬡ wine
803
931
  # ⬡ whisky
@@ -809,7 +937,7 @@ If the user changes or deletes a filter, the choices previously selected remain
809
937
 
810
938
  The `filter` option is not compatible with `enum`.
811
939
 
812
- ### 2.6.3 enum_select
940
+ ### 2.6.4 enum_select
813
941
 
814
942
  In order to ask for standard selection from indexed list you can use `enum_select` and pass question together with possible choices:
815
943
 
@@ -19,3 +19,4 @@ environment:
19
19
  - ruby_version: "23-x64"
20
20
  - ruby_version: "24"
21
21
  - ruby_version: "24-x64"
22
+ - ruby_version: "25-x64"
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative "../lib/tty-prompt"
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ choices = [
8
+ "Atom",
9
+ {name: "Emacs", disabled: '(not installed)'},
10
+ "GNU nano",
11
+ {name: "Notepad++", disabled: '(not installed)'},
12
+ "Sublime",
13
+ "Vim"
14
+ ]
15
+
16
+ prompt.enum_select('Select an editor', choices)
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../lib/tty-prompt'
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ quotes = [
8
+ "There are certain queer times and occasions in this strange mixed affair we call life when a man takes this whole universe for a vast practical joke, though the wit thereof he but dimly discerns, and more than suspects that the joke is at nobody's expense but his own.",
9
+ "Talk not to me of blasphemy, man;\n I'd strike the sun if it insulted me.",
10
+ "There is a wisdom that is woe; but there is a woe that is madness. And there is a Catskill eagle in some souls that can alike dive down into the blackest gorges, and soar out of them again and become invisible in the sunny spaces. And even if he for ever flies within the gorge, that gorge is in the mountains; so that even in his lowest swoop the mountain eagle is still higher than other birds upon the plain, even though they soar."
11
+ ]
12
+
13
+ answer = prompt.enum_select('Chose your quote?', quotes)
14
+
15
+ puts "Answer: #{answer}"
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative "../lib/tty-prompt"
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ drinks = [
8
+ {name: 'sake', disabled: '(out of stock)'},
9
+ 'vodka',
10
+ {name: 'beer', disabled: '(out of stock)'},
11
+ 'wine',
12
+ 'whisky',
13
+ 'bourbon'
14
+ ]
15
+ answer = prompt.multi_select('Choose your favourite drink?', drinks, default: 2)
16
+
17
+ puts answer.inspect
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../lib/tty-prompt'
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ quotes = [
8
+ "There are certain queer times and occasions in this strange mixed affair we call life when a man takes this whole universe for a vast practical joke, though the wit thereof he but dimly discerns, and more than suspects that the joke is at nobody's expense but his own.",
9
+ "Talk not to me of blasphemy, man; I'd strike the sun if it insulted me.",
10
+ "There is a wisdom that is woe; but there is a woe that is madness. And there is a Catskill eagle in some souls that can alike dive down into the blackest gorges, and soar out of them again and become invisible in the sunny spaces. And even if he for ever flies within the gorge, that gorge is in the mountains; so that even in his lowest swoop the mountain eagle is still higher than other birds upon the plain, even though they soar."
11
+ ]
12
+
13
+ answer = prompt.multi_select('Choose your quote?', quotes, echo: false)
14
+
15
+ puts "Answer: #{answer}"
@@ -15,4 +15,6 @@ prompt.on(:keypress) do |event|
15
15
  end
16
16
  end
17
17
 
18
- prompt.select('Choose your destiny?', warriors)
18
+ answer = prompt.select('Choose your destiny?', warriors)
19
+
20
+ puts answer.inspect
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative "../lib/tty-prompt"
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ warriors = [
8
+ 'Scorpion',
9
+ 'Kano',
10
+ { name: 'Goro', disabled: '(injury)' },
11
+ 'Jax',
12
+ 'Kitana',
13
+ 'Raiden'
14
+ ]
15
+
16
+ answer = prompt.select('Choose your destiny?', warriors, enum: ')')
17
+
18
+ puts answer.inspect
File without changes
@@ -6,4 +6,6 @@ prompt = TTY::Prompt.new
6
6
 
7
7
  warriors = %w(Scorpion Kano Jax Kitana Raiden)
8
8
 
9
- prompt.select('Choose your destiny?', warriors, filter: true)
9
+ answer = prompt.select('Choose your destiny?', warriors, filter: true)
10
+
11
+ puts answer.inspect
@@ -6,4 +6,6 @@ prompt = TTY::Prompt.new
6
6
 
7
7
  alfabet = ('A'..'Z').to_a
8
8
 
9
- prompt.select('Which letter?', alfabet, per_page: 8)
9
+ answer = prompt.select('Which letter?', alfabet, per_page: 8)
10
+
11
+ puts answer.inspect
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require_relative '../lib/tty-prompt'
4
+
5
+ prompt = TTY::Prompt.new
6
+
7
+ quotes = [
8
+ "There are certain queer times and occasions in this strange mixed affair we call life when a man takes this whole universe for a vast practical joke, though the wit thereof he but dimly discerns, and more than suspects that the joke is at nobody's expense but his own.",
9
+ "Talk not to me of blasphemy, man;\n I'd strike the sun if it insulted me.",
10
+ "There is a wisdom that is woe; but there is a woe that is madness. And there is a Catskill eagle in some souls that can alike dive down into the blackest gorges, and soar out of them again and become invisible in the sunny spaces. And even if he for ever flies within the gorge, that gorge is in the mountains; so that even in his lowest swoop the mountain eagle is still higher than other birds upon the plain, even though they soar."
11
+ ]
12
+
13
+ answer = prompt.select('Chose your quote?', quotes)
14
+
15
+ puts "Answer: #{answer}"
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'forwardable'
4
5
  require 'pastel'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module TTY
4
5
  class Prompt
@@ -1,32 +1,23 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  module TTY
4
5
  class Prompt
5
- # A single choice option
6
+ # An immutable representation of a single choice option from select menu
6
7
  #
7
8
  # @api public
8
9
  class Choice
9
- # The label name
10
+ # Create choice from value
10
11
  #
11
- # @api public
12
- attr_reader :name
13
-
14
- attr_reader :key
15
-
16
- # Create a Choice instance
12
+ # @examples
13
+ # Choice.from(:foo)
14
+ # # => <TTY::Prompt::Choice @key=nil @name="foo" @value="foo" @disabled=false>
17
15
  #
18
- # @api public
19
- def initialize(name, value, key = nil)
20
- @name = name
21
- @value = value
22
- @key = key
23
- end
24
-
25
- # Create choice from value
16
+ # Choice.from([:foo, 1])
17
+ # # => <TTY::Prompt::Choice @key=nil @name="foo" @value=1 @disabled=false>
26
18
  #
27
- # @example
28
- # Choice.from(:option_1)
29
- # Choice.from([:option_1, 1])
19
+ # Choice.from({name: :foo, value: 1, key: 'f'}
20
+ # # => <TTY::Prompt::Choice @key="f" @name="foo" @value=1 @disabled=false>
30
21
  #
31
22
  # @param [Object] val
32
23
  # the value to be converted
@@ -43,18 +34,67 @@ module TTY
43
34
  when String, Symbol
44
35
  new(val, val)
45
36
  when Array
46
- new("#{val.first}", val.last)
47
- when Hash
48
- if val.key?(:name)
49
- new("#{val[:name]}", val[:value], val[:key])
37
+ name, value, options = *val
38
+ if name.is_a?(Hash)
39
+ convert_hash(name)
50
40
  else
51
- new("#{val.keys.first}", val.values.first)
41
+ new(name.to_s, value || name.to_s, options || {})
52
42
  end
43
+ when Hash
44
+ convert_hash(val)
53
45
  else
54
46
  raise ArgumentError, "#{val} cannot be coerced into Choice"
55
47
  end
56
48
  end
57
49
 
50
+ # Convert hash into choice
51
+ #
52
+ # @api public
53
+ def self.convert_hash(val)
54
+ if val.key?(:name) && val.key?(:value)
55
+ new(val[:name].to_s, val[:value], val)
56
+ elsif val.key?(:name)
57
+ new(val[:name].to_s, val[:name].to_s, val)
58
+ else
59
+ new(val.keys.first.to_s, val.values.first)
60
+ end
61
+ end
62
+
63
+ # The label name
64
+ #
65
+ # @api public
66
+ attr_reader :name
67
+
68
+ # The keyboard key to activate this choice
69
+ #
70
+ # @api public
71
+ attr_reader :key
72
+
73
+ # The text to display for disabled choice
74
+ #
75
+ # @api public
76
+ attr_reader :disabled
77
+
78
+ # Create a Choice instance
79
+ #
80
+ # @api public
81
+ def initialize(name, value, **options)
82
+ @name = name
83
+ @value = value
84
+ @key = options[:key]
85
+ @disabled = options[:disabled].nil? ? false : options[:disabled]
86
+ freeze
87
+ end
88
+
89
+ # Check if this choice is disabled
90
+ #
91
+ # @return [Boolean]
92
+ #
93
+ # @api public
94
+ def disabled?
95
+ !!@disabled
96
+ end
97
+
58
98
  # Read value and evaluate
59
99
  #
60
100
  # @api public
@@ -74,7 +114,9 @@ module TTY
74
114
  # @api public
75
115
  def ==(other)
76
116
  return false unless other.is_a?(self.class)
77
- name == other.name && value == other.value
117
+ name == other.name &&
118
+ value == other.value &&
119
+ key == other.key
78
120
  end
79
121
 
80
122
  # Object string representation