Class: PSD::Resource::Section::ResolutionInfo
- Defined in:
- lib/psd/resources/resolution_info.rb
Constant Summary collapse
- RES_UNIT_NAMES =
%w(pixel/inch pixel/cm).freeze
- UNIT_NAMES =
%w(in cm pt picas columns).freeze
Instance Attribute Summary collapse
-
#h_res ⇒ Object
readonly
Returns the value of attribute h_res.
-
#h_res_unit ⇒ Object
readonly
Returns the value of attribute h_res_unit.
-
#height_unit ⇒ Object
readonly
Returns the value of attribute height_unit.
-
#v_res ⇒ Object
readonly
Returns the value of attribute v_res.
-
#v_res_unit ⇒ Object
readonly
Returns the value of attribute v_res_unit.
-
#width_unit ⇒ Object
readonly
Returns the value of attribute width_unit.
Instance Method Summary collapse
- #h_res_unit_name ⇒ Object
- #height_unit_name ⇒ Object
- #parse ⇒ Object
- #v_res_unit_name ⇒ Object
- #width_unit_name ⇒ Object
Methods inherited from Base
#initialize, name, #name, #resource_id, resource_id
Constructor Details
This class inherits a constructor from PSD::Resource::Section::Base
Instance Attribute Details
#h_res ⇒ Object (readonly)
Returns the value of attribute h_res.
13 14 15 |
# File 'lib/psd/resources/resolution_info.rb', line 13 def h_res @h_res end |
#h_res_unit ⇒ Object (readonly)
Returns the value of attribute h_res_unit.
13 14 15 |
# File 'lib/psd/resources/resolution_info.rb', line 13 def h_res_unit @h_res_unit end |
#height_unit ⇒ Object (readonly)
Returns the value of attribute height_unit.
14 15 16 |
# File 'lib/psd/resources/resolution_info.rb', line 14 def height_unit @height_unit end |
#v_res ⇒ Object (readonly)
Returns the value of attribute v_res.
14 15 16 |
# File 'lib/psd/resources/resolution_info.rb', line 14 def v_res @v_res end |
#v_res_unit ⇒ Object (readonly)
Returns the value of attribute v_res_unit.
14 15 16 |
# File 'lib/psd/resources/resolution_info.rb', line 14 def v_res_unit @v_res_unit end |
#width_unit ⇒ Object (readonly)
Returns the value of attribute width_unit.
13 14 15 |
# File 'lib/psd/resources/resolution_info.rb', line 13 def width_unit @width_unit end |
Instance Method Details
#h_res_unit_name ⇒ Object
30 31 32 |
# File 'lib/psd/resources/resolution_info.rb', line 30 def h_res_unit_name RES_UNIT_NAMES.fetch(h_res_unit - 1, 'unknown') end |
#height_unit_name ⇒ Object
42 43 44 |
# File 'lib/psd/resources/resolution_info.rb', line 42 def height_unit_name UNIT_NAMES.fetch(height_unit - 1, 'unknown') end |
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/psd/resources/resolution_info.rb', line 16 def parse # 32-bit fixed-point number (16.16) @h_res = @file.read_uint.to_f / (1 << 16) @h_res_unit = @file.read_ushort @width_unit = @file.read_ushort # 32-bit fixed-point number (16.16) @v_res = @file.read_uint.to_f / (1 << 16) @v_res_unit = @file.read_ushort @height_unit = @file.read_ushort @resource.data = self end |
#v_res_unit_name ⇒ Object
34 35 36 |
# File 'lib/psd/resources/resolution_info.rb', line 34 def v_res_unit_name RES_UNIT_NAMES.fetch(v_res_unit - 1, 'unknown') end |
#width_unit_name ⇒ Object
38 39 40 |
# File 'lib/psd/resources/resolution_info.rb', line 38 def width_unit_name UNIT_NAMES.fetch(width_unit - 1, 'unknown') end |