32 lines
679 B
Ruby
32 lines
679 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Repubmark
|
|
module Elems
|
|
class Fraction < Base
|
|
parents :Joint
|
|
|
|
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
|
|
|
|
#################
|
|
# Basic methods #
|
|
#################
|
|
|
|
def word_count = 1
|
|
|
|
def to_summary_plain = "#@top/#@bottom".freeze
|
|
|
|
def to_html = "<sup>#@top</sup>⁄<sub>#@bottom</sub>".freeze
|
|
|
|
def to_gemtext = "#@top/#@bottom".freeze
|
|
end
|
|
end
|
|
end
|