list_picker 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +43 -2
- data/lib/list_picker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e44d28753c071d15b3b6c59cab66c2bbed2d779
|
4
|
+
data.tar.gz: 120d5e8f9d88079bab0fafca701e3495170ec356
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3dd305754aa1f0921ab0f2ff553dd98546cdc6b92bf7edf99bd695e1625a90b3aa9c7691fcfc7345057efd2b4c219ca45f31ba677b20631197fe4ccea739745
|
7
|
+
data.tar.gz: 92c2efff589075d108aeb8f27f791ef2459ffbce6ddc58036ed56b52a05d0ecb284437c046a6c909204ce17acef84d34de006bd4f4c2f11e2ac86b6b34fbe5a0
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ListPicker
|
2
2
|
|
3
|
-
|
3
|
+
Library for prompting users for input
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,7 +20,48 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
```ruby
|
24
|
+
require 'list_picker'
|
25
|
+
|
26
|
+
array = %w{ Option1 Option2 Option3 }
|
27
|
+
chosen_option = ListPicker::Picker.new(array).ask("Please select from list of available options")
|
28
|
+
```
|
29
|
+
|
30
|
+
### Using objects
|
31
|
+
|
32
|
+
You can use objects and define method that will be used to be displayed in the list. In order to do that, you can pass in options to the constructor:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'list_picker'
|
36
|
+
|
37
|
+
array = (1..10).map do |i|
|
38
|
+
Time.new(Time.now.year + i)
|
39
|
+
end
|
40
|
+
|
41
|
+
chosen_option = ListPicker::Picker.new(array, label_method: :year).ask("Please select a year from the list")
|
42
|
+
```
|
43
|
+
|
44
|
+
### Batch mode
|
45
|
+
|
46
|
+
ListPicker reads arguments passed into the script so that you can predefine your ansers. For instance:
|
47
|
+
|
48
|
+
Take for example file *test.rb* with contents:
|
49
|
+
```ruby
|
50
|
+
require 'list_picker'
|
51
|
+
|
52
|
+
array = (1..10).map do |i|
|
53
|
+
Time.new(Time.now.year + i)
|
54
|
+
end
|
55
|
+
|
56
|
+
chosen_option = ListPicker::Picker.new(array, label_method: :year).ask("Please select a year from the list")
|
57
|
+
```
|
58
|
+
You can then invoke it by calling:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
ruby test.rb 4
|
62
|
+
```
|
63
|
+
|
64
|
+
This will have preselected 4th option from the list
|
24
65
|
|
25
66
|
## Contributing
|
26
67
|
|
data/lib/list_picker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: list_picker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislaw Wozniak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|