Class: Coradoc::Element::Image::Core
- Extended by:
- AttributeList::Matchers
- Defined in:
- lib/coradoc/element/image/core.rb
Direct Known Subclasses
Constant Summary collapse
- VALIDATORS_POSITIONAL =
[ [:alt, String], [:width, Integer], [:height, Integer], ]
- VALIDATORS_NAMED =
{ id: String, alt: String, fallback: String, title: String, width: Integer, height: Integer, link: String, # change to that URI regexp window: String, scale: Integer, scaledwidth: /\A[0-9]{1,2}%\z/, pdfwidth: /\A[0-9]+vw\z/, role: many(/.*/, "left", "right", "th", "thumb", "related", "rel"), opts: many("nofollow", "noopener", "inline", "interactive"), }
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#id ⇒ Object
Returns the value of attribute id.
-
#src ⇒ Object
Returns the value of attribute src.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, id, src, options = {}) ⇒ Core
constructor
A new instance of Core.
- #to_adoc ⇒ Object
Methods included from AttributeList::Matchers
Methods inherited from Base
#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit
Constructor Details
#initialize(title, id, src, options = {}) ⇒ Core
Returns a new instance of Core.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/coradoc/element/image/core.rb', line 9 def initialize(title, id, src, = {}) @title = title @id = id @anchor = @id.nil? ? nil : Inline::Anchor.new(@id) @src = src @attributes = .fetch(:attributes, AttributeList.new) @annotate_missing = .fetch(:annotate_missing, nil) @title = .fetch(:title, nil) unless @title if @attributes.any? @attributes.validate_positional(VALIDATORS_POSITIONAL) @attributes.validate_named(VALIDATORS_NAMED) end @line_break = .fetch(:line_break, "") end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def attributes @attributes end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def id @id end |
#src ⇒ Object
Returns the value of attribute src.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def src @src end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/coradoc/element/image/core.rb', line 5 def title @title end |
Instance Method Details
#to_adoc ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/coradoc/element/image/core.rb', line 24 def to_adoc missing = "// FIXME: Missing image: #{@annotate_missing}\n" if @annotate_missing anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n" title = ".#{@title}\n" unless @title.to_s.empty? attrs = @attributes_macro.to_adoc [missing, anchor, title, "image", @colons, @src, attrs, @line_break].join("") end |