pdf-core 0.0.1 → 0.0.2

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: 1e04dbc623a502e35e4ab9879b4e418a22799525
4
- data.tar.gz: 8bcd0c9a82f9330fa074af80e43f8f371edba50f
3
+ metadata.gz: c1db7a454bf4818e0320591f85425fba5c81d83c
4
+ data.tar.gz: 35ddcc1adc2c2649d54d416c0f29d9f9b46ed837
5
5
  SHA512:
6
- metadata.gz: ede1498abbf6a6a93e1410cd019c320beb0b490a64ebbbf2bc1d13c2ba56e257e098db49da253444a7dbc70482a28b8ca1f8dd41bf9fa310a88080856a1445e5
7
- data.tar.gz: d872d4b0b03aab9bd55bb3a1c2caa855280bbb6216e1ca89bcd0fd4aa9329f70893a846e0db53fd826a4069c1300e1f100369b88e7ba976d0d9ff49b50c4d9d7
6
+ metadata.gz: 8c1b1717b67cdec541fe441231f28a56e7d46f09a9d050c99d6b0f9b8332abdc210f03b633c13ded533ca6969a5813c65ab3f37f0e36847edad5e19f90ac1889
7
+ data.tar.gz: c83828520b846dd237afe54d0d7e578a965e536434d8fc8e30b6d060bfcf42851ad1804a7d207d619c3a98662c607ee897315d7ecb29efd4e8dec360d75d4917
@@ -43,17 +43,23 @@ module PDF
43
43
 
44
44
  end
45
45
 
46
+ # NOTE: This class may be a good candidate for a copy-on-write hash.
46
47
  class GraphicState
47
- attr_accessor :color_space, :dash, :cap_style, :join_style, :line_width, :fill_color, :stroke_color
48
+ attr_accessor :color_space, :dash, :cap_style, :join_style, :line_width,
49
+ :fill_color, :stroke_color
48
50
 
49
51
  def initialize(previous_state = nil)
50
- @color_space = previous_state ? previous_state.color_space.dup : {}
51
- @fill_color = previous_state ? previous_state.fill_color : "000000"
52
- @stroke_color = previous_state ? previous_state.stroke_color : "000000"
53
- @dash = previous_state ? previous_state.dash : { :dash => nil, :space => nil, :phase => 0 }
54
- @cap_style = previous_state ? previous_state.cap_style : :butt
55
- @join_style = previous_state ? previous_state.join_style : :miter
56
- @line_width = previous_state ? previous_state.line_width : 1
52
+ if previous_state
53
+ initialize_copy(previous_state)
54
+ else
55
+ @color_space = {}
56
+ @fill_color = "000000"
57
+ @stroke_color = "000000"
58
+ @dash = { :dash => nil, :space => nil, :phase => 0 }
59
+ @cap_style = :butt
60
+ @join_style = :miter
61
+ @line_width = 1
62
+ end
57
63
  end
58
64
 
59
65
  def dash_setting
@@ -63,6 +69,22 @@ module PDF
63
69
  "[#{@dash[:dash]} #{@dash[:space]}] #{@dash[:phase]} d"
64
70
  end
65
71
  end
72
+
73
+ private
74
+
75
+ def initialize_copy(other)
76
+ # mutable state
77
+ @color_space = other.color_space.dup
78
+ @fill_color = other.fill_color.dup
79
+ @stroke_color = other.stroke_color.dup
80
+ @dash = other.dash.dup
81
+
82
+ # immutable state that doesn't need to be duped
83
+ @cap_style = other.cap_style
84
+ @join_style = other.join_style
85
+ @line_width = other.line_width
86
+ end
66
87
  end
67
88
  end
68
89
  end
90
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-12-24 00:00:00.000000000 Z
15
+ date: 2014-01-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pdf-reader
@@ -138,3 +138,4 @@ signing_key:
138
138
  specification_version: 4
139
139
  summary: PDF::Core is used by Prawn to render PDF documents
140
140
  test_files: []
141
+ has_rdoc: