RDoc::Generator::SolarFish Example
class
Bird

The base class for all birds.

Instance Methods
instance method
public
fly
Bird.fly(symbol, number) -> bool
Bird.fly(string, number) -> bool

Fly somewhere.

Flying is the most critical feature of birds.

Example

fly(:south, 70)
Source code
# File example.rb, line 51
def fly(direction, velocity)
  _fly_impl(direction, velocity)
end
instance method
public
speak
speak() { |text| ... }

Produce some noise.

Source code
# File example.rb, line 32
def speak # :yields: text
  puts 'generic tweeting'
  yield 'tweet'
  yield 'tweet'
end
class
Duck

A duck is a Waterfowl Bird.

Features:

bird::

  * speak
  * fly

waterfowl::

  * swim
Extended Classes
extended
Animal

            
Included Modules
included
Waterfowl

            
Constants
constant
MAX_VELOCITY

            
Class Methods
class method
public
new
new(domestic, rubber)

Creates a new duck.

Source code
# File example.rb, line 114
def initialize(domestic, rubber)
  @domestic = domestic
  @rubber = rubber
  @@rubber_ducks << self if rubber
end
class method
public
rubber_ducks
rubber_ducks()

Returns list of all rubber ducks.

Source code
# File example.rb, line 109
def self.rubber_ducks
  @@rubber_ducks
end
Instance Attributes
instance attribute
public
domestic

            

True for domestic ducks.

instance attribute
public
rubber

            

True for rubber ducks.

Instance Methods
instance method
private
quack
quack()

Implements quacking

Source code
# File example.rb, line 86
def quack
  'quack'
end
instance method
public
speak
speak() { |speech| ... }

Duck overrides generic implementation.

Source code
# File example.rb, line 80
def speak
  speech = quack
  yield speech
end
instance method
public
useful?
Bird.useful? -> bool

Checks if this duck is a useful one.

Source code
# File example.rb, line 124
def useful?
  @domestic || @rubber
end
class
Object
Constants
constant
DEFAULT_DUCK_VELOCITY

            

Default velocity for a flying duck.

module
Waterfowl

A mixin for waterfowl creatures.

Instance Methods
instance method
public
swim
swim()

Swimming helper.

Source code
# File example.rb, line 19
def swim
  puts 'swimming around'
end