ircp 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ircp/message.rb CHANGED
@@ -7,9 +7,25 @@ module Ircp
7
7
  def initialize(*args)
8
8
  options = args.last.is_a?(Hash) ? args.pop : {}
9
9
  @raw = options[:raw]
10
- @prefix = options[:prefix].is_a?(Hash) ? Prefix.new(options[:prefix]) : nil
10
+ @prefix = Prefix.new(options[:prefix] || {})
11
11
  @command = options[:command]
12
12
  @params = args
13
13
  end
14
+
15
+ def inspect
16
+ variables = instance_variables.map { |name| "#{name.inspect}=#{instance_variable_get(name).inspect}" }
17
+ variables.unshift "#{self.class}"
18
+ "<#{variables.join ' '}>"
19
+ end
20
+
21
+ def to_s
22
+ return @raw unless @raw.nil?
23
+
24
+ tokens = []
25
+ tokens.push @prefix unless @prefix.empty?
26
+ tokens.push @command unless @command.nil?
27
+ tokens.push *@params
28
+ tokens.join ' '
29
+ end
14
30
  end
15
31
  end
data/lib/ircp/prefix.rb CHANGED
@@ -9,5 +9,29 @@ module Ircp
9
9
  @user = options[:user]
10
10
  @host = options[:host]
11
11
  end
12
+
13
+ def empty?
14
+ to_s.empty?
15
+ end
16
+
17
+ def inspect
18
+ variables = instance_variables.map { |name| "#{name.inspect}=#{instance_variable_get(name).inspect}" }
19
+ variables.unshift "#{self.class}"
20
+ "<#{variables.join ' '}>"
21
+ end
22
+
23
+ def to_s
24
+ return @raw unless @raw.nil?
25
+
26
+ if @servername
27
+ ":#{servername}"
28
+ else
29
+ tokens = []
30
+ tokens.push ":#{@nick}" unless @nick.nil?
31
+ tokens.push "!#{@user}" unless @user.nil?
32
+ tokens.push "@#{@host}" unless @host.nil?
33
+ tokens.join ''
34
+ end
35
+ end
12
36
  end
13
37
  end
data/lib/ircp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ircp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ircp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-02-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: treetop
16
- requirement: &18199220 !ruby/object:Gem::Requirement
16
+ requirement: &12892860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18199220
24
+ version_requirements: *12892860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &18198800 !ruby/object:Gem::Requirement
27
+ requirement: &12892440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *18198800
35
+ version_requirements: *12892440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &18198380 !ruby/object:Gem::Requirement
38
+ requirement: &12892020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *18198380
46
+ version_requirements: *12892020
47
47
  description: irc parser
48
48
  email:
49
49
  - mail@mashiro.org
@@ -92,3 +92,4 @@ signing_key:
92
92
  specification_version: 3
93
93
  summary: irc parser for ruby
94
94
  test_files: []
95
+ has_rdoc: