Class: PureDocx::XmlGenerators::Image
- Defined in:
- lib/puredocx/xml_generators/image.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#image_name ⇒ Object
readonly
Returns the value of attribute image_name.
-
#image_path ⇒ Object
readonly
Returns the value of attribute image_path.
-
#in_header ⇒ Object
readonly
Returns the value of attribute in_header.
-
#rels_id ⇒ Object
readonly
Returns the value of attribute rels_id.
-
#size_constructor ⇒ Object
readonly
Returns the value of attribute size_constructor.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(image_path, rels_constructor, arguments = {}) ⇒ Image
constructor
A new instance of Image.
- #params ⇒ Object
- #template ⇒ Object
- #xml ⇒ Object
Constructor Details
#initialize(image_path, rels_constructor, arguments = {}) ⇒ Image
Returns a new instance of Image.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puredocx/xml_generators/image.rb', line 13 def initialize(image_path, rels_constructor, arguments = {}) super(nil, rels_constructor) @image_path = image_path @image_name = File.basename(image_path) ensure_file! @width = arguments[:width] @height = arguments[:height] @in_header = arguments[:in_header] @align = arguments[:align] @rels_id = "rId#{appropriated_rels_size}" @size_constructor = PureDocx::Constructors::ImageSize.new( user_params: [width, height], real_params: FastImage.size(image_path) ) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def align @align end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def height @height end |
#image_name ⇒ Object (readonly)
Returns the value of attribute image_name.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def image_name @image_name end |
#image_path ⇒ Object (readonly)
Returns the value of attribute image_path.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def image_path @image_path end |
#in_header ⇒ Object (readonly)
Returns the value of attribute in_header.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def in_header @in_header end |
#rels_id ⇒ Object (readonly)
Returns the value of attribute rels_id.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def rels_id @rels_id end |
#size_constructor ⇒ Object (readonly)
Returns the value of attribute size_constructor.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def size_constructor @size_constructor end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
4 5 6 |
# File 'lib/puredocx/xml_generators/image.rb', line 4 def width @width end |
Instance Method Details
#params ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puredocx/xml_generators/image.rb', line 34 def params align_params = { horizontal: '', vertical: '' } align_params.merge! prepare_align_params(align) if align { '{WIDTH}' => size_constructor.prepare_size[:width], '{HEIGHT}' => size_constructor.prepare_size[:height], '{RID}' => rels_id, '{NAME}' => image_name, '{UNIQUE_NAME}' => uniq_name(image_name), '{HORIZONTAL_ALIGN}' => align_params[:horizontal], '{VERTICAL_ALIGN}' => align_params[:vertical] } end |
#template ⇒ Object
48 49 50 51 |
# File 'lib/puredocx/xml_generators/image.rb', line 48 def template return File.read(DocArchive.template_path('float_image.xml')) if align&.any? File.read(DocArchive.template_path('image.xml')) end |
#xml ⇒ Object
29 30 31 32 |
# File 'lib/puredocx/xml_generators/image.rb', line 29 def xml add_image_rels super end |