Class: Repubmark::Elems::Fraction
- Defined in:
- lib/repubmark/elems/fraction.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(parent, top, bottom) ⇒ Fraction
constructor
A new instance of Fraction.
- #to_gemtext ⇒ Object
- #to_html ⇒ Object
- #to_summary_plain ⇒ Object
-
#word_count ⇒ Object
Basic methods #.
Methods inherited from Base
#absolute_url, #config, #count_words, #html_class, #own_url, parent?, parents, #relative_url
Constructor Details
#initialize(parent, top, bottom) ⇒ Fraction
Returns a new instance of Fraction.
8 9 10 11 12 13 14 15 16 |
# File 'lib/repubmark/elems/fraction.rb', line 8 def initialize(parent, top, bottom) super parent @top = Integer top @bottom = Integer bottom raise 'Expected top to be non-negative' if @top.negative? raise 'Expected bottom to be positive' unless @bottom.positive? end |
Instance Method Details
#to_gemtext ⇒ Object
28 |
# File 'lib/repubmark/elems/fraction.rb', line 28 def to_gemtext = "#@top/#@bottom".freeze |
#to_html ⇒ Object
26 |
# File 'lib/repubmark/elems/fraction.rb', line 26 def to_html = "<sup>#@top</sup>⁄<sub>#@bottom</sub>".freeze |
#to_summary_plain ⇒ Object
24 |
# File 'lib/repubmark/elems/fraction.rb', line 24 def to_summary_plain = "#@top/#@bottom".freeze |
#word_count ⇒ Object
Basic methods #
22 |
# File 'lib/repubmark/elems/fraction.rb', line 22 def word_count = 1 |