Class: Quby::Compiler::Entities::Text
- Defined in:
- lib/quby/compiler/entities/text.rb
Instance Attribute Summary collapse
-
#col_span ⇒ Object
In case of being displayed inside a table, amount of columns/rows to span.
-
#display_in ⇒ Object
Returns the value of attribute display_in.
-
#html_content ⇒ Object
Returns the value of attribute html_content.
-
#key ⇒ Object
Returns the value of attribute key.
-
#row_span ⇒ Object
Returns the value of attribute row_span.
-
#str ⇒ Object
readonly
Returns the value of attribute str.
Attributes inherited from Item
#presentation, #raw_content, #switch_cycle
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_json(options = {}) ⇒ Object
- #html ⇒ Object
-
#initialize(str = "", key:, md: nil, **options) ⇒ Text
constructor
str is deprecated, use named md instead.
- #text ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #validate_answer(answer_hash) ⇒ Object
Constructor Details
#initialize(str = "", key:, md: nil, **options) ⇒ Text
str is deprecated, use named md instead. str fallback to empty string for quby1 compatibility.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/quby/compiler/entities/text.rb', line 20 def initialize(str="", key:, md: nil, **) if [:html_content] [:raw_content] = "<div class='item text'>" + [:html_content] + "</div>" end super() @key = key @str = md || str @html_content = [:html_content] @display_in = [:display_in] || [:paged] @col_span = [:col_span] || 1 @row_span = [:row_span] || 1 end |
Instance Attribute Details
#col_span ⇒ Object
In case of being displayed inside a table, amount of columns/rows to span
14 15 16 |
# File 'lib/quby/compiler/entities/text.rb', line 14 def col_span @col_span end |
#display_in ⇒ Object
Returns the value of attribute display_in.
10 11 12 |
# File 'lib/quby/compiler/entities/text.rb', line 10 def display_in @display_in end |
#html_content ⇒ Object
Returns the value of attribute html_content.
11 12 13 |
# File 'lib/quby/compiler/entities/text.rb', line 11 def html_content @html_content end |
#key ⇒ Object
Returns the value of attribute key.
16 17 18 |
# File 'lib/quby/compiler/entities/text.rb', line 16 def key @key end |
#row_span ⇒ Object
Returns the value of attribute row_span.
15 16 17 |
# File 'lib/quby/compiler/entities/text.rb', line 15 def row_span @row_span end |
#str ⇒ Object (readonly)
Returns the value of attribute str.
9 10 11 |
# File 'lib/quby/compiler/entities/text.rb', line 9 def str @str end |
Instance Method Details
#==(other) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/quby/compiler/entities/text.rb', line 54 def ==(other) case other.class when String text == other when self.class text == other.text else false end end |
#as_json(options = {}) ⇒ Object
33 34 35 |
# File 'lib/quby/compiler/entities/text.rb', line 33 def as_json( = {}) super().merge(text: text) end |
#html ⇒ Object
37 38 39 |
# File 'lib/quby/compiler/entities/text.rb', line 37 def html @html_content || text end |
#text ⇒ Object
41 42 43 44 |
# File 'lib/quby/compiler/entities/text.rb', line 41 def text return "" if str.blank? @text ||= Quby::Compiler::MarkdownParser.new(str).to_html end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/quby/compiler/entities/text.rb', line 65 def to_s text end |
#type ⇒ Object
46 47 48 |
# File 'lib/quby/compiler/entities/text.rb', line 46 def type "text" end |
#validate_answer(answer_hash) ⇒ Object
50 51 52 |
# File 'lib/quby/compiler/entities/text.rb', line 50 def validate_answer(answer_hash) true end |