Class: FallCli::BrowserHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fallcli/browser_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#positionObject

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_downObject



25
26
27
# File 'lib/fallcli/browser_helper.rb', line 25

def position_down
  @position += 1 unless @position == (@files.size - 1)
end

#position_upObject



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_filesObject



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