Class: Kanrisuru::Mode::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/mode/permission.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(numeric, symbolic) ⇒ Permission

Returns a new instance of Permission.



8
9
10
11
12
13
# File 'lib/kanrisuru/mode/permission.rb', line 8

def initialize(numeric, symbolic)
  @numeric = numeric
  @symbolic = symbolic

  update_symbolic_rwx
end

Instance Attribute Details

#symbolicObject

Returns the value of attribute symbolic.



6
7
8
# File 'lib/kanrisuru/mode/permission.rb', line 6

def symbolic
  @symbolic
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/kanrisuru/mode/permission.rb', line 27

def all?
  read? && write? && execute?
end

#execute=(boolean) ⇒ Object



59
60
61
62
63
64
# File 'lib/kanrisuru/mode/permission.rb', line 59

def execute=(boolean)
  @executable = boolean

  update_numeric
  update_symbolic
end

#execute?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/kanrisuru/mode/permission.rb', line 74

def execute?
  @executable
end

#numericObject



23
24
25
# File 'lib/kanrisuru/mode/permission.rb', line 23

def numeric
  @numeric.to_s
end

#numeric=(numeric) ⇒ Object



38
39
40
41
42
43
# File 'lib/kanrisuru/mode/permission.rb', line 38

def numeric=(numeric)
  @numeric = numeric

  update_numeric_rwx
  update_symbolic
end

#read=(boolean) ⇒ Object



45
46
47
48
49
50
# File 'lib/kanrisuru/mode/permission.rb', line 45

def read=(boolean)
  @readable = boolean

  update_numeric
  update_symbolic
end

#read?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/kanrisuru/mode/permission.rb', line 66

def read?
  @readable
end

#to_iObject



15
16
17
# File 'lib/kanrisuru/mode/permission.rb', line 15

def to_i
  numeric.to_i
end

#to_sObject



19
20
21
# File 'lib/kanrisuru/mode/permission.rb', line 19

def to_s
  symbolic
end

#write=(boolean) ⇒ Object



52
53
54
55
56
57
# File 'lib/kanrisuru/mode/permission.rb', line 52

def write=(boolean)
  @writeable = boolean

  update_numeric
  update_symbolic
end

#write?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/kanrisuru/mode/permission.rb', line 70

def write?
  @writeable
end