Module: MarketBeat

Defined in:
lib/market_beat/version.rb,
lib/market_beat.rb,
lib/market_beat/yahoo.rb,
lib/market_beat/google.rb,
lib/market_beat/historical.rb

Overview

Copyright © 2011-12 Michael Dvorkin

Market Beat is freely distributable under the terms of MIT license. See LICENSE file or www.opensource.org/licenses/mit-license.php


Defined Under Namespace

Classes: Google, Historical, Yahoo

Constant Summary collapse

@@methods =

Pre-cache available methods so we could use them within method_missing where respond_to? gives false positives.

{ :historical => [ :quotes ] }

Class Method Summary collapse

Class Method Details

.method_missing(method, *args, &blk) ⇒ Object

Proxy MarketBeat methods to either Google or Yahoo providers.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/market_beat.rb', line 24

def self.method_missing(method, *args, &blk)
  if @@methods[:google].include?(method)
    Google.send(method, *args)
  elsif @@methods[:yahoo].include?(method)
    Yahoo.send(method, *args)
  elsif @@methods[:historical].include?(method)
    Historical.send(method, *args)
  else
    super
  end
end

.respond_to_missing?(method, include_private) ⇒ Boolean

Make MarketBeat.respond_to? return true for all the methods above.

Returns:

  • (Boolean)


38
39
40
# File 'lib/market_beat.rb', line 38

def self.respond_to_missing?(method, include_private)
  super(method, include_private) || @@methods.values.flatten.include?(method)
end

.versionObject



7
8
9
# File 'lib/market_beat/version.rb', line 7

def self.version
  '0.2.0'
end