Class: Bitcoin::Analyzer
- Inherits:
-
Object
- Object
- Bitcoin::Analyzer
- Defined in:
- lib/bitcoin/analyzer.rb
Class Method Summary collapse
- .analyze_trades(symbol) ⇒ Object
- .get_max(object_array, attribute = :price) ⇒ Object
- .get_min(object_array, attribute = :price) ⇒ Object
Class Method Details
.analyze_trades(symbol) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bitcoin/analyzer.rb', line 15 def self.analyze_trades(symbol) trades = Bitcoin::Trade.get_trades_in_range(symbol.id) puts "" puts " ///// [Analysis Results] /////" puts "|" puts "| Trade with highest price:" puts "| #{self.get_max(trades).display_details}" puts "| Trade with lowest price:" puts "| #{self.get_min(trades).display_details}" puts "| Largest trade:" puts "| #{self.get_max(trades, :quantity).display_details}" end |
.get_max(object_array, attribute = :price) ⇒ Object
3 4 5 6 7 |
# File 'lib/bitcoin/analyzer.rb', line 3 def self.get_max(object_array, attribute = :price) object_array.max_by{ |e| e.send("#{attribute}") } end |
.get_min(object_array, attribute = :price) ⇒ Object
9 10 11 12 13 |
# File 'lib/bitcoin/analyzer.rb', line 9 def self.get_min(object_array, attribute = :price) object_array.min_by{ |e| e.send("#{attribute}") } end |