adts 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4162fbb5e18982b4036110f988f631d07eed48b9
4
- data.tar.gz: d96dd1f30153023ea1f390f6d0a4351c15283c6a
3
+ metadata.gz: fa28e2d1509e8a2c7a19e507d9ed235b536361ae
4
+ data.tar.gz: 8f7ee9ff5b0a60341d1f8d7dcb51757543737e21
5
5
  SHA512:
6
- metadata.gz: 04d46f79094e626edd1369bb192db2708108eb15766e8117f553d31233214c70ab260bc1f31d279119ecc7103c332a6635a99a6f25278b2ba80c8f61f5d3c87c
7
- data.tar.gz: b50b446aaf64d21917f107467dd6a15891ddba0a284b128d61c4a0bd7886be296f46ead77e1903e023472d017611818378f19f1658b4c845916acc73a8aef586
6
+ metadata.gz: 57503b9ef4b9fc7ee141cc3f6b88a9be8d39dfa87ed5da79c08d0fcbb14dd5335136d7f4e08f1bcf8880a8b4f55f1e60e2a7565e1df3942bf91168e857b922f2
7
+ data.tar.gz: 810adff8d25a8638b2e76e07c81cbb3d9be02330a26bb72b48e197c3c0c7619a170fe9e1f0d511f0d0689c66be7bb39bf0aed84e491675d6c449b2031e24e8c0
@@ -21,6 +21,11 @@ module ADT
21
21
  def ==(other)
22
22
  other.is_a?(self.class) && #{keys.empty? ? "true" : keys.map { |key| "#{key} == other.#{key}"}.join(" && ")}
23
23
  end
24
+
25
+ def to_s
26
+ self.class.name.split('::').last + '(' + instance_variables.map { |i| i.to_s[1..-1] + ': ' + instance_variable_get(i).inspect }.join(', ') + ')'
27
+ end
28
+ alias inspect to_s
24
29
  "
25
30
  @parameters = parameters
26
31
  @others = []
@@ -1,3 +1,3 @@
1
1
  module ADT
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -44,4 +44,9 @@ describe ADT do
44
44
  it 'uses subtyping' do
45
45
  expect(Shape::Circle(1)).to be_kind_of(Shape)
46
46
  end
47
+
48
+ it 'implements to_s and inspect' do
49
+ expect(Shape::Circle(1).to_s).to eq("Circle(radius: 1)")
50
+ expect(Shape::Rectangle(1, 2).inspect).to eq("Rectangle(width: 1, height: 2)")
51
+ end
47
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Bach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-22 00:00:00.000000000 Z
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -100,3 +100,4 @@ summary: Abstract Data Types for Ruby
100
100
  test_files:
101
101
  - spec/adt_spec.rb
102
102
  - spec/spec_helper.rb
103
+ has_rdoc: