Sha256: b70e6ce3f53fc90ab3ca17f6d44349796093514e532830b785e19377365bb6d0

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

module RubyLabs
  
=begin rdoc

== IntroLab

The IntroLab module has Ruby code described in from Chapter 2 of <em>Explorations in Computing</em>.
These simple examples illustrate how methods are defined in Ruby.

=end

module IntroLab

  # Compute the area of a 5-sided counter that is a square with a missing
  # triangle shape.  The parameter +x+ is the length of one side of the square.
  #
  #-- 
  # :begin :countertop 
  def countertop(x)
    square = x**2
    triangle = ((x/2)**2) / 2
    return square - triangle
  end
  # :end :countertop

  # Convert the temperature +f+ (in degrees Fahrenheit) into the equivalent
  # temperature in degrees Celsius.
  #
  #-- 
  # :begin :celsius
    def celsius(f)
      (f - 32) * 5 / 9
    end
  # :end :celsius

  # Stub for a method to convert temperature +c+ (in degrees Celsius) into the equivalent temperature
  # in degrees Fahrenheit
  #
  #-- 
  # :begin :fahrenheit
    def fahrenheit(c)
      # your expression goes here
    end
  # :end :fahrenheit

end # IntroLab

end # RubyLabs

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rubylabs-1.0.2 lib/introlab.rb
rubylabs-1.0.1 lib/introlab.rb
rubylabs-1.0.0 lib/introlab.rb
rubylabs-0.9.8 lib/introlab.rb
rubylabs-0.9.7 lib/introlab.rb
rubylabs-0.9.6 lib/introlab.rb
rubylabs-0.9.5 lib/introlab.rb
rubylabs-0.9.4 lib/introlab.rb
rubylabs-0.9.3 lib/introlab.rb
rubylabs-0.9.2 lib/introlab.rb
rubylabs-0.9.1 lib/introlab.rb