Class: ListedFile

Inherits:
ActiveWindow::ListedItem show all
Defined in:
lib/listed_file.rb

Direct Known Subclasses

ListedDirectory

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveWindow::ListedItem

build, #hide!, #icon, #matches?, #message?, modify_icon, new_by_iter, new_by_reference, #reference, #reference=, #separator?, #to_s, #visible?

Constructor Details

#initialize(opts = {}) ⇒ ListedFile

Returns a new instance of ListedFile.



18
19
20
21
22
23
24
# File 'lib/listed_file.rb', line 18

def initialize(opts = {})
  super
  if fp = opts[:full_path]
    self.full_path = fp
    self.status = "normal" if VimMate::Config[:files_show_status]
  end
end

Instance Attribute Details

#full_pathObject

Returns the value of attribute full_path.



2
3
4
# File 'lib/listed_file.rb', line 2

def full_path
  @full_path
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/listed_file.rb', line 2

def name
  @name
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/listed_file.rb', line 2

def status
  @status
end

Class Method Details

.create(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/listed_file.rb', line 4

def self.create(opts = {})
  if fp = opts[:full_path]
    if File.directory?(fp)
      ListedDirectory.new opts
    elsif File.file?(fp)
      ListedFile.new opts
    else
      raise ArgumentError, "does not exist: #{fp}"
    end
  else
    raise ArgumentError, "please give a :full_path, not only #{opts.inspect}"
  end
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/listed_file.rb', line 48

def directory?
  false
end

#exists?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/listed_file.rb', line 51

def exists?
  full_path && ::File.file?(full_path)
end

#file?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/listed_file.rb', line 45

def file?
  true
end

#file_or_directory?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/listed_file.rb', line 54

def file_or_directory?
  file? || directory?
end

#icon_nameObject



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

def icon_name
  'file'
end

#refreshObject



28
29
30
31
32
33
# File 'lib/listed_file.rb', line 28

def refresh
  Gtk.queue do
    self.icon = VimMate::Icons.by_name icon_name
    self.status = "normal" if VimMate::Config[:files_show_status]
  end
end

#show!Object



58
59
60
61
62
63
64
# File 'lib/listed_file.rb', line 58

def show!
  i = iter
  while i = i.parent
    i[VISIBLE] = true
  end
  super
end

#sortObject



42
43
44
# File 'lib/listed_file.rb', line 42

def sort
  "2-#{name}-1"
end