Class: Ykytils::DirEntryItem
- Inherits:
-
Object
- Object
- Ykytils::DirEntryItem
- Defined in:
- lib/ykutils/lsutils.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#group ⇒ Object
Returns the value of attribute group.
-
#month ⇒ Object
Returns the value of attribute month.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_dir ⇒ Object
Returns the value of attribute parent_dir.
-
#path ⇒ Object
Returns the value of attribute path.
-
#size ⇒ Object
Returns the value of attribute size.
-
#time ⇒ Object
Returns the value of attribute time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user ⇒ Object
Returns the value of attribute user.
-
#valid ⇒ Object
Returns the value of attribute valid.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
- #group_perm ⇒ Object
-
#initialize ⇒ DirEntryItem
constructor
A new instance of DirEntryItem.
- #otherr_perm ⇒ Object
- #owner_perm ⇒ Object
- #parse(str, parent_dir, valid = true) ⇒ Object
- #to_csv ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ DirEntryItem
Returns a new instance of DirEntryItem.
8 |
# File 'lib/ykutils/lsutils.rb', line 8 def initialize; end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def day @day end |
#group ⇒ Object
Returns the value of attribute group.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def group @group end |
#month ⇒ Object
Returns the value of attribute month.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def month @month end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def name @name end |
#parent_dir ⇒ Object
Returns the value of attribute parent_dir.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def parent_dir @parent_dir end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def size @size end |
#time ⇒ Object
Returns the value of attribute time.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def time @time end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def type @type end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def user @user end |
#valid ⇒ Object
Returns the value of attribute valid.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def valid @valid end |
#year ⇒ Object
Returns the value of attribute year.
6 7 8 |
# File 'lib/ykutils/lsutils.rb', line 6 def year @year end |
Instance Method Details
#directory? ⇒ Boolean
51 52 53 |
# File 'lib/ykutils/lsutils.rb', line 51 def directory? @type === :DIRECTORY end |
#file? ⇒ Boolean
55 56 57 |
# File 'lib/ykutils/lsutils.rb', line 55 def file? @type === :FILE end |
#group_perm ⇒ Object
63 64 65 |
# File 'lib/ykutils/lsutils.rb', line 63 def group_perm @perm.group end |
#otherr_perm ⇒ Object
67 68 69 |
# File 'lib/ykutils/lsutils.rb', line 67 def otherr_perm @perm.other end |
#owner_perm ⇒ Object
59 60 61 |
# File 'lib/ykutils/lsutils.rb', line 59 def owner_perm @perm.owner end |
#parse(str, parent_dir, valid = true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ykutils/lsutils.rb', line 10 def parse(str, parent_dir, valid = true) ary = str.split(/\s+/) perm = ary[0] @type = if perm[0].chr == "d" :DIRECTORY else :FILE end @perm = FilePermision.new(ary[0][1..9]) @value = ary[1] @user = ary[2] @group = ary[3] @size = ary[4] @month = ary[5] @day = ary[6] str = ary[7] if str =~ /:/ @year = Time.now.year @time = str else @year = str @time = "00:00:00" end @time = ary[7] @name = ary[8] @path = File.join(parent_dir, @name) @parent_dir = parent_dir @valid = valid end |
#to_csv ⇒ Object
47 48 49 |
# File 'lib/ykutils/lsutils.rb', line 47 def to_csv "#{@type},#{@perm},#{@value},#{@user},#{@group},#{@size},#{@year},#{@month},#{@day},#{@time},#{@name},#{@parent_dir},#{@valid}" end |
#to_hash ⇒ Object
41 42 43 44 45 |
# File 'lib/ykutils/lsutils.rb', line 41 def to_hash { "type" => @type, "perm" => @perm.to_hash, "value" => @value, "user" => @user, "group" => @group, "size" => @size, "month" => @month, "day" => @day, "year" => @year, "time" => @time, "name" => @name, "path" => @path, "parent_dir" => @parent_dir, "valid" => @valid } end |