Class: Hamidashi
- Inherits:
-
Object
- Object
- Hamidashi
- Defined in:
- lib/hamidashi.rb,
lib/hamidashi/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#percentage ⇒ Object
readonly
Returns the value of attribute percentage.
Instance Method Summary collapse
-
#initialize(percentage, pdf_path) ⇒ Hamidashi
constructor
A new instance of Hamidashi.
- #overflow?(page) ⇒ Boolean
- #pdf_page_count ⇒ Object
- #save_page(page, path) ⇒ Object
- #save_preview_page(page, path) ⇒ Object
Constructor Details
#initialize(percentage, pdf_path) ⇒ Hamidashi
Returns a new instance of Hamidashi.
7 8 9 10 |
# File 'lib/hamidashi.rb', line 7 def initialize(percentage, pdf_path) @percentage = percentage / 100r @pdf_path = pdf_path end |
Instance Attribute Details
#percentage ⇒ Object (readonly)
Returns the value of attribute percentage.
5 6 7 |
# File 'lib/hamidashi.rb', line 5 def percentage @percentage end |
Instance Method Details
#overflow?(page) ⇒ Boolean
12 13 14 15 16 17 18 19 |
# File 'lib/hamidashi.rb', line 12 def overflow?(page) cropped_page_img = cropped_img(page) colornum = cropped_page_img.color_histogram.count cropped_page_img.destroy! expected_colornum != colornum end |
#pdf_page_count ⇒ Object
35 36 37 |
# File 'lib/hamidashi.rb', line 35 def pdf_page_count pdf_image_list.count end |
#save_page(page, path) ⇒ Object
21 22 23 |
# File 'lib/hamidashi.rb', line 21 def save_page(page, path) pdf_image_list[page].write(path) end |
#save_preview_page(page, path) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/hamidashi.rb', line 25 def save_preview_page(page, path) page_img = pdf_image_list[page].dup draw_preview_frame(page).draw(page_img) page_img.write(path) page_img.destroy! end |