Class: Lsd::Entry
- Inherits:
-
Object
- Object
- Lsd::Entry
- Defined in:
- lib/lsd/entry.rb
Instance Attribute Summary collapse
-
#stat ⇒ Object
readonly
Returns the value of attribute stat.
Instance Method Summary collapse
-
#initialize(name) ⇒ Entry
constructor
A new instance of Entry.
- #modified ⇒ Object
- #name ⇒ Object
- #raw_size ⇒ Object
- #size ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name) ⇒ Entry
Returns a new instance of Entry.
5 6 7 8 |
# File 'lib/lsd/entry.rb', line 5 def initialize(name) @full_path = name @stat = File.stat(name) end |
Instance Attribute Details
#stat ⇒ Object (readonly)
Returns the value of attribute stat.
3 4 5 |
# File 'lib/lsd/entry.rb', line 3 def stat @stat end |
Instance Method Details
#modified ⇒ Object
26 27 28 |
# File 'lib/lsd/entry.rb', line 26 def modified @modified ||= format_time_ago(stat.mtime) end |
#name ⇒ Object
10 11 12 |
# File 'lib/lsd/entry.rb', line 10 def name @name ||= File.basename(@full_path) end |
#raw_size ⇒ Object
22 23 24 |
# File 'lib/lsd/entry.rb', line 22 def raw_size @raw_size ||= calculate_size end |
#size ⇒ Object
18 19 20 |
# File 'lib/lsd/entry.rb', line 18 def size @size ||= format_size(raw_size) end |
#type ⇒ Object
14 15 16 |
# File 'lib/lsd/entry.rb', line 14 def type @type ||= directory? ? "dir".light_blue : "file".light_black end |