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
- #otherr_perm ⇒ Object
- #owner_perm ⇒ Object
- #parse(str, parent_dir, valid: true) ⇒ Object
- #to_csv ⇒ Object
- #to_hash ⇒ Object
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
49 50 51 |
# File 'lib/ykutils/lsutils.rb', line 49 def directory? @type == :DIRECTORY end |
#file? ⇒ Boolean
53 54 55 |
# File 'lib/ykutils/lsutils.rb', line 53 def file? @type == :FILE end |
#group_perm ⇒ Object
61 62 63 |
# File 'lib/ykutils/lsutils.rb', line 61 def group_perm @perm.group end |
#otherr_perm ⇒ Object
65 66 67 |
# File 'lib/ykutils/lsutils.rb', line 65 def otherr_perm @perm.other end |
#owner_perm ⇒ Object
57 58 59 |
# File 'lib/ykutils/lsutils.rb', line 57 def owner_perm @perm.owner end |
#parse(str, parent_dir, valid: true) ⇒ Object
8 9 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 |
# File 'lib/ykutils/lsutils.rb', line 8 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
45 46 47 |
# File 'lib/ykutils/lsutils.rb', line 45 def to_csv "#{@type},#{@perm},#{@value},#{@user},#{@group},#{@size},#{@year},#{@month},#{@day},#{@time},#{@name},#{@parent_dir},#{@valid}" end |
#to_hash ⇒ Object
39 40 41 42 43 |
# File 'lib/ykutils/lsutils.rb', line 39 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 |