Permalink
Browse files

Style cleanup

  • Loading branch information...
1 parent ddf2e83 commit dd7124d7debeaf5b7fb6377ce1b18bff2f4c87bc @meh committed Feb 23, 2012
@@ -20,11 +20,9 @@
module IRC; class Events
class Aliases < Hash
- def initialize
- super {|hash, key|
- hash[key] = Hash.new
- }
- end
+ def initialize
+ super { |h, k| h[k] = Hash.new }
+ end
end
end; end
@@ -20,26 +20,24 @@
module IRC; class Events
class Callback
- include Comparable
+ include Comparable
- attr_reader :method, :options
+ attr_reader :method, :options
- def initialize (options={}, &block)
- @block = block
- @options = options
+ def initialize (options={}, &block)
+ @block = block
+ @options = options
- raise ArgumentError, 'options has to be a Hash' unless @options.is_a?(Hash)
- end
+ raise ArgumentError, 'options has to be a Hash' unless @options.is_a?(Hash)
+ end
- def <=> (value)
- (options[:priority] || 0) <=> (value.options[:priority] || 0)
- end
+ def <=> (value)
+ (options[:priority] || 0) <=> (value.options[:priority] || 0)
+ end
- def call (*args, &block)
- begin
- @block.call(*args, &block)
- rescue LocalJumpError; end
- end
+ def call (*args, &block)
+ @block.call(*args, &block)
+ rescue LocalJumpError; end
end
end; end
@@ -20,13 +20,13 @@
module IRC; class Events
class Chains < Hash
- def initialize
- super {|hash, key|
- hash[key] = Hash.new {|hash, key|
- hash[key] = []
- }
- }
- end
+ def initialize
+ super {|hash, key|
+ hash[key] = Hash.new {|hash, key|
+ hash[key] = []
+ }
+ }
+ end
end
end; end
@@ -20,11 +20,9 @@
module IRC; class Events
class Custom < Hash
- def initialize
- super {|hash, key|
- hash[key] = []
- }
- end
+ def initialize
+ super { |h, k| h[k] = [] }
+ end
end
end; end
@@ -41,7 +41,7 @@ def input (&block)
def output (&block)
tmp, @into = @into, :output
- self.instance_eval(&block)
+ instance_eval &block
@into = tmp
end
@@ -50,7 +50,7 @@ def aliases (&block)
return @aliases unless @into
on = InsensitiveStruct.new
- on.instance_eval(&block)
+ on.instance_eval &block
on.to_hash.each {|name, value|
@aliases[@into][name] = value
View
@@ -20,58 +20,58 @@
module IRC
class Mask
- def self.escape (str)
- Regexp.escape(str).gsub(/\\\*/, '[^!@]*?').gsub(/\\\?/, '[^!@]') rescue '[^!@]*?'
- end
+ def self.escape (str)
+ Regexp.escape(str).gsub(/\\\*/, '[^!@]*?').gsub(/\\\?/, '[^!@]') rescue '[^!@]*?'
+ end
- attr_accessor :nick, :user, :host
+ attr_accessor :nick, :user, :host
- def initialize (nick=nil, user=nil, host=nil)
- @nick = nick
- @user = user
- @host = host
- end
+ def initialize (nick=nil, user=nil, host=nil)
+ @nick = nick
+ @user = user
+ @host = host
+ end
- def match (mask)
- mask = Mask.parse(mask) if !mask.is_a?(Mask)
+ def match (mask)
+ mask = Mask.parse(mask) if !mask.is_a?(Mask)
- !!(mask.is_a?(Mask) ? mask : Mask.parse(mask || '*!*@*')).to_s.match(self.to_reg)
- end
+ !!(mask.is_a?(Mask) ? mask : Mask.parse(mask || '*!*@*')).to_s.match(self.to_reg)
+ end
- def == (mask)
- mask = Mask.parse(mask) if !mask.is_a?(Mask)
+ def == (mask)
+ mask = Mask.parse(mask) if !mask.is_a?(Mask)
- @nick == mask.nick && @user == mask.user && @host == mask.host
- end
+ @nick == mask.nick && @user == mask.user && @host == mask.host
+ end
- def to_s
- "#{@nick || '*'}!#{@user || '*'}@#{@host || '*'}"
- end
+ def to_s
+ "#{@nick || '*'}!#{@user || '*'}@#{@host || '*'}"
+ end
- def to_reg
- Regexp.new("^(?:(#{Mask.escape(@nick)})(?:!|$))?(?:(#{Mask.escape(@user)})(?:@|$))(?:(#{Mask.escape(@host)}))?$", 'i')
- end
+ def to_reg
+ Regexp.new("^(?:(#{Mask.escape(@nick)})(?:!|$))?(?:(#{Mask.escape(@user)})(?:@|$))(?:(#{Mask.escape(@host)}))?$", 'i')
+ end
- def self.parse (mask)
- Mask.new *mask.scan(/^
- # nickname
- (?:
- ([^@!]*?) # nickname can contains all chars excluding '@' and '!'
- (?:!|$) # it must be followed by a '!' or end of string
- )?
+ def self.parse (mask)
+ Mask.new *mask.scan(/^
+ # nickname
+ (?:
+ ([^@!]*?) # nickname can contains all chars excluding '@' and '!'
+ (?:!|$) # it must be followed by a '!' or end of string
+ )?
- # username
- (?:
- ([^@!]*?) # username can contain all chars excluding '@' and '!'
- (?:@|$) # it must be followed by a '@' or end of string
- )?
+ # username
+ (?:
+ ([^@!]*?) # username can contain all chars excluding '@' and '!'
+ (?:@|$) # it must be followed by a '@' or end of string
+ )?
- # hostname
- (.*?) # hostname can contain all chars
- $/x).flatten.map {|part|
- part.empty? ? nil : part
- } rescue []
- end
+ # hostname
+ (.*?) # hostname can contain all chars
+ $/x).flatten.map {|part|
+ part.empty? ? nil : part
+ } rescue []
+ end
end
end
Oops, something went wrong.

0 comments on commit dd7124d

Please sign in to comment.