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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -2
  3. data/lib/list_picker/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 956f1f09cbca9c90c918f56ed1d8bd82729907fa
4
- data.tar.gz: bce0fcceef1a29da84342e75373e659d857e282f
3
+ metadata.gz: 9e44d28753c071d15b3b6c59cab66c2bbed2d779
4
+ data.tar.gz: 120d5e8f9d88079bab0fafca701e3495170ec356
5
5
  SHA512:
6
- metadata.gz: 83c9c17704423eda4876cade074cd60b5d937c50bf15421ad59c4bf99909d164db3d2442282fc6cd0d4dabd9fb1a91dacb6e1088e8466650b2a1495ac210a24a
7
- data.tar.gz: 1b7f244bf1c636ebc1f2aa0a7f925672b4f0e0576e31ebce050d65e0ec7b03ec4595b5fbbb796b3a5af964e1bfa1e03edde7660e62c3a2c45a64b0982046d5e5
6
+ metadata.gz: c3dd305754aa1f0921ab0f2ff553dd98546cdc6b92bf7edf99bd695e1625a90b3aa9c7691fcfc7345057efd2b4c219ca45f31ba677b20631197fe4ccea739745
7
+ data.tar.gz: 92c2efff589075d108aeb8f27f791ef2459ffbce6ddc58036ed56b52a05d0ecb284437c046a6c909204ce17acef84d34de006bd4f4c2f11e2ac86b6b34fbe5a0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ListPicker
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -1,3 +1,3 @@
1
1
  module ListPicker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-17 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler