Class: FallCli::BrowserHelper
- Inherits:
-
Object
- Object
- FallCli::BrowserHelper
- Defined in:
- lib/fallcli/browser_helper.rb
Instance Attribute Summary collapse
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(items) ⇒ BrowserHelper
constructor
A new instance of BrowserHelper.
- #position_down ⇒ Object
- #position_up ⇒ Object
- #pretty_dropbox_file(file) ⇒ Object
- #show_files ⇒ Object
Constructor Details
#initialize(items) ⇒ BrowserHelper
Returns a new instance of BrowserHelper.
5 6 7 8 9 |
# File 'lib/fallcli/browser_helper.rb', line 5 def initialize items @files = Array.new items.each { |item| @files << item } @position = 0 end |
Instance Attribute Details
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/fallcli/browser_helper.rb', line 3 def position @position end |
Instance Method Details
#position_down ⇒ Object
25 26 27 |
# File 'lib/fallcli/browser_helper.rb', line 25 def position_down @position += 1 unless @position == (@files.size - 1) end |
#position_up ⇒ Object
21 22 23 |
# File 'lib/fallcli/browser_helper.rb', line 21 def position_up @position -= 1 unless @position < 1 end |
#pretty_dropbox_file(file) ⇒ Object
17 18 19 |
# File 'lib/fallcli/browser_helper.rb', line 17 def pretty_dropbox_file file "#{file.path} | #{file.mime_type} | #{file.size}" end |
#show_files ⇒ Object
11 12 13 14 15 |
# File 'lib/fallcli/browser_helper.rb', line 11 def show_files @files.each_with_index.map do |item, index| position == index ? "[#{pretty_dropbox_file(item)}]" : " #{pretty_dropbox_file(item)} " end end |