Skip to content

Instantly share code, notes, and snippets.

@lsegal
Forked from amireh/yard-appendix-fixture.rb
Created February 1, 2013 07:58
Show Gist options
  • Save lsegal/4690030 to your computer and use it in GitHub Desktop.
Save lsegal/4690030 to your computer and use it in GitHub Desktop.
require 'bundler'
Bundler.require(:default)
# Currency
#
# A transaction currency.
#
class Currency
attr_reader :exchange_rate
# converts an amount from an original currency to this one
# curr can be either a String or a Currency
#
# @example
# def foo()
# puts "hello!"
# end
# @param curr [String] the source currency code
# @param amt [Float] the amount to convert
# @return [Float] the normalized amount
# @see #to
def from(curr, amt)
c = curr.is_a?(String) ? Currency[curr] : curr
(c.normalize(amt) * self.rate).round(2)
end
# converts an amount from this currency to another one
# curr can be a String or a Currency
#
# @see Currency::Appendix_2 Appendix: Currencies
def to(curr, amt)
c = curr.is_a?(String) ? Currency[curr] : curr
c.from(self, amt)
end
# converts the given amount to USD based on this currency rate
def normalize(amt)
amt / self.rate
end
alias_method :n, :normalize
# koo
class Tester
def foo
end
class Kaboom
def foo
end
# @appendix Appendix: KABOOM!
#
# DOM DOM
end
# @appendix Appendix: Foobar
#
# Adooken.
end
# BOOYAH
def bar
end
# @appendix Appendix: Currencies
#
# This is an appendix entry.
#
# {include:file:test.md}
#
# @appendix Appendix: Gooka
#
# This is **another appendix** entry.
#
# @example
# def foo()
# puts "hello!"
# end
#
# @see Currency
#
# Lorem ipsum
# Vestibulum
# Nunc iaculis sapien
#
# You can also check out Tester for more information.
#
# @see Tester
# @see Currency#from
#
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment