Class: Repubmark::Elems::Fraction

Inherits:
Base
  • Object
show all
Defined in:
lib/repubmark/elems/fraction.rb

Instance Attribute Summary

Attributes inherited from Base

#parent

Instance Method Summary collapse

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_gemtextObject



28
# File 'lib/repubmark/elems/fraction.rb', line 28

def to_gemtext = "#@top/#@bottom".freeze

#to_htmlObject



26
# File 'lib/repubmark/elems/fraction.rb', line 26

def to_html = "<sup>#@top</sup>&frasl;<sub>#@bottom</sub>".freeze

#to_summary_plainObject



24
# File 'lib/repubmark/elems/fraction.rb', line 24

def to_summary_plain = "#@top/#@bottom".freeze

#word_countObject

Basic methods #



22
# File 'lib/repubmark/elems/fraction.rb', line 22

def word_count = 1