Class: JekyllIS::Images::Kramdown::Value
- Inherits:
-
Object
- Object
- JekyllIS::Images::Kramdown::Value
- Defined in:
- lib/jekyll-is/images/kramdown/value.rb
Instance Attribute Summary collapse
- #attrs ⇒ Hash<String => String> readonly
- #classes ⇒ Set<String> readonly
- #context ⇒ JekyllIS::Images::Context readonly
- #flags ⇒ Set<String> readonly
- #id ⇒ String readonly
- #styles ⇒ Hash<String => String> readonly
Instance Method Summary collapse
- #apply(element) ⇒ self
- #category ⇒ Symbol
-
#initialize(context) ⇒ Value
constructor
A new instance of Value.
- #to_html ⇒ String
- #to_kramdown ⇒ Kramdown::Element
- #to_latex ⇒ String
- #type ⇒ Symbol
Constructor Details
#initialize(context) ⇒ Value
Returns a new instance of Value.
16 17 18 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 16 def initialize context @context = context end |
Instance Attribute Details
#attrs ⇒ Hash<String => String> (readonly)
46 47 48 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 46 def attrs @attrs end |
#classes ⇒ Set<String> (readonly)
55 56 57 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 55 def classes @classes end |
#context ⇒ JekyllIS::Images::Context (readonly)
13 14 15 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 13 def context @context end |
#flags ⇒ Set<String> (readonly)
49 50 51 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 49 def flags @flags end |
#id ⇒ String (readonly)
52 53 54 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 52 def id @id end |
#styles ⇒ Hash<String => String> (readonly)
58 59 60 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 58 def styles @styles end |
Instance Method Details
#apply(element) ⇒ self
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 62 def apply element @attrs ||= {} @attrs.merge!(element.attr&.dup || {}) @flags ||= Set::new @flags.merge(element.&.dig(:ial, :refs) || []) @id ||= @attrs.delete('id') @classes ||= Set::new @classes.merge(@attrs.delete('class')&.split(' ') || []) @styles ||= {} @styles.merge!(@attrs.delete('style')&.split(';')&.map { it.split(':', 2) }&.to_h || {}) self end |
#category ⇒ Symbol
31 32 33 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 31 def category raise NotImplementedError, 'Abstract method call' end |
#to_html ⇒ String
36 37 38 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 36 def to_html raise NotImplementedError, 'Abstract method call' end |
#to_kramdown ⇒ Kramdown::Element
21 22 23 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 21 def to_kramdown Kramdown::Element::new self.type, self, nil, category: self.category end |
#to_latex ⇒ String
41 42 43 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 41 def to_latex raise NotImplementedError, 'Abstract method call' end |
#type ⇒ Symbol
26 27 28 |
# File 'lib/jekyll-is/images/kramdown/value.rb', line 26 def type raise NotImplementedError, 'Abstract method call' end |