Class: Ru::File
- Inherits:
-
Object
- Object
- Ru::File
- Defined in:
- lib/ru/file.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #basename ⇒ Object (also: #name)
- #ctime ⇒ Object (also: #created_at)
- #extname ⇒ Object
- #format(format = 'l') ⇒ Object
- #ftype ⇒ Object
- #gid ⇒ Object
- #group ⇒ Object
-
#initialize(path) ⇒ File
constructor
A new instance of File.
- #mode ⇒ Object
- #mtime ⇒ Object (also: #updated_at)
- #omode ⇒ Object
- #owner ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
- #uid ⇒ Object
- #world_readable? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
5 6 7 |
# File 'lib/ru/file.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#<=>(other) ⇒ Object
76 77 78 |
# File 'lib/ru/file.rb', line 76 def <=>(other) name <=> other.name end |
#basename ⇒ Object Also known as: name
9 10 11 |
# File 'lib/ru/file.rb', line 9 def basename delegate_to_file(:basename) end |
#ctime ⇒ Object Also known as: created_at
13 14 15 |
# File 'lib/ru/file.rb', line 13 def ctime delegate_to_file(:ctime) end |
#extname ⇒ Object
17 18 19 |
# File 'lib/ru/file.rb', line 17 def extname delegate_to_file(:extname) end |
#format(format = 'l') ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ru/file.rb', line 21 def format(format='l') separator = "\t" case format when 'l' datetime = ctime.strftime(%w{%Y-%m-%d %H:%M}.join(separator)) return [omode, owner, group, size, datetime, name].join(separator) else raise 'format not supported' end end |
#ftype ⇒ Object
32 33 34 |
# File 'lib/ru/file.rb', line 32 def ftype delegate_to_file(:ftype) end |
#gid ⇒ Object
36 37 38 |
# File 'lib/ru/file.rb', line 36 def gid delegate_to_stat(:gid) end |
#group ⇒ Object
40 41 42 |
# File 'lib/ru/file.rb', line 40 def group Etc.getgrgid(gid).name end |
#mode ⇒ Object
44 45 46 |
# File 'lib/ru/file.rb', line 44 def mode delegate_to_stat(:mode) end |
#mtime ⇒ Object Also known as: updated_at
48 49 50 |
# File 'lib/ru/file.rb', line 48 def mtime delegate_to_file(:mtime) end |
#omode ⇒ Object
52 53 54 |
# File 'lib/ru/file.rb', line 52 def omode '%o' % world_readable? end |
#owner ⇒ Object
56 57 58 |
# File 'lib/ru/file.rb', line 56 def owner Etc.getpwuid(uid).name end |
#size ⇒ Object
60 61 62 |
# File 'lib/ru/file.rb', line 60 def size delegate_to_file(:size) end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/ru/file.rb', line 64 def to_s name end |
#uid ⇒ Object
68 69 70 |
# File 'lib/ru/file.rb', line 68 def uid delegate_to_stat(:uid) end |
#world_readable? ⇒ Boolean
72 73 74 |
# File 'lib/ru/file.rb', line 72 def world_readable? delegate_to_stat(:world_readable?) end |