Class: TinyIRC::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/tinyirc/perms.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, command, branch) ⇒ Permission

Returns a new instance of Permission.



10
11
12
13
14
# File 'lib/tinyirc/perms.rb', line 10

def initialize(plugin, command, branch)
  @plugin  = plugin
  @command = command
  @branch  = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



2
3
4
# File 'lib/tinyirc/perms.rb', line 2

def branch
  @branch
end

#commandObject (readonly)

Returns the value of attribute command.



2
3
4
# File 'lib/tinyirc/perms.rb', line 2

def command
  @command
end

#pluginObject (readonly)

Returns the value of attribute plugin.



2
3
4
# File 'lib/tinyirc/perms.rb', line 2

def plugin
  @plugin
end

Class Method Details

.parse(pstr) ⇒ Object

Raises:

  • (RuntimeError)


4
5
6
7
8
# File 'lib/tinyirc/perms.rb', line 4

def self.parse(pstr)
  a = pstr.split('/', 3)
  raise RuntimeError, "Invalid permission: #{pstr}" unless a[0] || !a[1] && a[2]
  [a[0], a[1] || :all, a[2] || :all]
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/tinyirc/perms.rb', line 16

def ==(other)
  @plugin == other.plugin && @command == other.command && @branch == other.branch
end

#to_sObject



20
21
22
# File 'lib/tinyirc/perms.rb', line 20

def to_s
  "#{@plugin}/#{@command}/#{@branch}"
end