Class: TradingviewScreener::Predicate

Inherits:
Object
  • Object
show all
Defined in:
lib/tradingview_screener/predicate.rb

Overview

Arel-like column node used inside where().

Screener[:close].gt(Screener[:SMA20])
Screener[:volume].gte(1_000_000)
Screener[:close].between(10, 300)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, operation, right = nil) ⇒ Predicate

Returns a new instance of Predicate.



12
13
14
15
16
# File 'lib/tradingview_screener/predicate.rb', line 12

def initialize(left, operation, right = nil)
  @left = left.to_s
  @operation = operation.to_s
  @right = unwrap(right)
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



10
11
12
# File 'lib/tradingview_screener/predicate.rb', line 10

def left
  @left
end

#operationObject (readonly)

Returns the value of attribute operation.



10
11
12
# File 'lib/tradingview_screener/predicate.rb', line 10

def operation
  @operation
end

#rightObject (readonly)

Returns the value of attribute right.



10
11
12
# File 'lib/tradingview_screener/predicate.rb', line 10

def right
  @right
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/tradingview_screener/predicate.rb', line 22

def inspect
  "#<#{self.class} #{left} #{operation} #{right.inspect}>"
end

#to_hObject



18
19
20
# File 'lib/tradingview_screener/predicate.rb', line 18

def to_h
  { "left" => left, "operation" => operation, "right" => right }
end