class DinosaurCatalog::Dinosaur

Constants

BIG_DINOSAUR_LBS
POUNDS_PER_TON

Attributes

continent[R]
description[R]
diet[R]
name[R]
period[R]
walking[R]
weight_in_lbs[R]

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/dinosaur_catalog/dinosaur.rb, line 8
def initialize(name, options = {})
  @name = name
  @period = options[:period]
  @continent = options[:continent]
  @diet = options[:diet]
  @weight_in_lbs = options[:weight_in_lbs]
  @walking = options[:walking]
  @description = options[:description]
end

Public Instance Methods

big?() click to toggle source
# File lib/dinosaur_catalog/dinosaur.rb, line 18
def big?
  weight_in_tons > BIG_DINOSAUR_LBS
end
small?() click to toggle source
# File lib/dinosaur_catalog/dinosaur.rb, line 22
def small?
  weight_in_tons > 0 && weight_in_tons <= BIG_DINOSAUR_LBS
end
to_hash() click to toggle source
# File lib/dinosaur_catalog/dinosaur.rb, line 30
def to_hash
  hash = {}
  instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
  hash
end
weight_in_tons() click to toggle source
# File lib/dinosaur_catalog/dinosaur.rb, line 26
def weight_in_tons
  @weight_in_lbs.to_i / POUNDS_PER_TON
end