downup 0.2.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c6e65b3f3072415591a30ea663da443baecfb82
4
- data.tar.gz: 1e523fd756f0a970b7787b1527241708cc458f89
3
+ metadata.gz: e35290acc75be20825a11b389b1a17fcf7b15e06
4
+ data.tar.gz: cfe3648f3ce916d3304be3340733bae086651e9c
5
5
  SHA512:
6
- metadata.gz: 11eeadb275adca911e8a52057022770071f21e3612bf1be12f649c5c6d2628b9237e7f2727b8843252abd471c917eca75bfafa7c823cb9d5d477443dba942d50
7
- data.tar.gz: 0deff0c531f8369ebbc652a1b030a413aca1aeb378abcff871dc3fe7fe6f6c383fc622f6871e166a85979b904b3f3fdf81edddaf0aa8a6bf406959bf0ebcc93f
6
+ metadata.gz: 0c707f040b07feb1e6e5bd0a257c3da8518884edb782c0000eeef734d3561ab1c326fd843617da1176168b392ba96a992b8553a4c7b61aed2dc3cff58d2060c4
7
+ data.tar.gz: d275a2dbe47176a8b6c59f3dddb9f7f1a27874f2c2a4abb44fb16458223cc2be6be2ff84b8791469ab5d649bae8c17928d2dbd9277a033fe1fe3e28f3208f432
data/README.md CHANGED
@@ -28,7 +28,10 @@ options = [
28
28
  "Kangaroo"
29
29
  ]
30
30
 
31
- Downup::Base.new(options).prompt
31
+ Downup::Base.new(options: options).prompt
32
+
33
+ # You can also pass a title when initializing
34
+ Downup::Base.new(options: options, title: "Animals: \n").prompt
32
35
  ```
33
36
 
34
37
  ## Inspired By
data/downup-0.3.2.gem ADDED
Binary file
@@ -1,3 +1,3 @@
1
1
  module Downup
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/downup.rb CHANGED
@@ -6,12 +6,15 @@ module Downup
6
6
  using Colors
7
7
 
8
8
  class Base
9
- def initialize(options)
9
+ def initialize(options:, title: nil)
10
10
  @options = options
11
+ @title = title
11
12
  end
12
13
 
13
14
  def prompt(position = 0)
14
15
  @selected_position = position_selector(position)
16
+ system("clear")
17
+ print_title
15
18
  print_options
16
19
  print "\n> "
17
20
  process_input read_char
@@ -19,7 +22,7 @@ module Downup
19
22
 
20
23
  private
21
24
 
22
- attr_reader :options, :selected_position
25
+ attr_reader :options, :title, :selected_position
23
26
 
24
27
  def process_input(input)
25
28
  case input
@@ -43,12 +46,17 @@ module Downup
43
46
  end
44
47
 
45
48
  def print_options
46
- system("clear")
47
49
  options.each_with_index do |option, index|
48
50
  puts index == selected_position ? option.bg_magenta : option
49
51
  end
50
52
  end
51
53
 
54
+ def print_title
55
+ return if title.nil?
56
+
57
+ puts "#{title}".red
58
+ end
59
+
52
60
  def read_char
53
61
  STDIN.echo = false
54
62
  STDIN.raw!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: downup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Begin
@@ -55,6 +55,7 @@ files:
55
55
  - Rakefile
56
56
  - bin/console
57
57
  - bin/setup
58
+ - downup-0.3.2.gem
58
59
  - downup.gemspec
59
60
  - lib/downup.rb
60
61
  - lib/downup/colors.rb