Class: Etherscanio::Call
- Inherits:
-
Object
- Object
- Etherscanio::Call
- Defined in:
- lib/etherscanio/call.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#address ⇒ Object
Returns the value of attribute address.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#blockno ⇒ Object
Returns the value of attribute blockno.
-
#blocktype ⇒ Object
Returns the value of attribute blocktype.
-
#endblock ⇒ Object
Returns the value of attribute endblock.
-
#mod ⇒ Object
Returns the value of attribute mod.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#page ⇒ Object
Returns the value of attribute page.
-
#sort ⇒ Object
Returns the value of attribute sort.
-
#startblock ⇒ Object
Returns the value of attribute startblock.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#txhash ⇒ Object
Returns the value of attribute txhash.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(mod, action) ⇒ Call
constructor
A new instance of Call.
- #to_s ⇒ Object
Constructor Details
#initialize(mod, action) ⇒ Call
Returns a new instance of Call.
18 19 20 21 22 23 |
# File 'lib/etherscanio/call.rb', line 18 def initialize(mod, action) @base = 'http://api.etherscan.io/api?' @mod = mod @action = action @api_key = false end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def action @action end |
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def address @address end |
#api_key ⇒ Object
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def api_key @api_key end |
#blockno ⇒ Object
Returns the value of attribute blockno.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def blockno @blockno end |
#blocktype ⇒ Object
Returns the value of attribute blocktype.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def blocktype @blocktype end |
#endblock ⇒ Object
Returns the value of attribute endblock.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def endblock @endblock end |
#mod ⇒ Object
Returns the value of attribute mod.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def mod @mod end |
#offset ⇒ Object
Returns the value of attribute offset.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def offset @offset end |
#page ⇒ Object
Returns the value of attribute page.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def page @page end |
#sort ⇒ Object
Returns the value of attribute sort.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def sort @sort end |
#startblock ⇒ Object
Returns the value of attribute startblock.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def startblock @startblock end |
#tag ⇒ Object
Returns the value of attribute tag.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def tag @tag end |
#txhash ⇒ Object
Returns the value of attribute txhash.
4 5 6 |
# File 'lib/etherscanio/call.rb', line 4 def txhash @txhash end |
Instance Method Details
#fetch ⇒ Object
25 26 27 28 29 |
# File 'lib/etherscanio/call.rb', line 25 def fetch res = RestClient.get(to_s, {}).body parsed = JSON.parse(res) JSON.generate(parsed) end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/etherscanio/call.rb', line 31 def to_s uri = 'module=' + mod + '&action=' + action uri += '&apikey=' + api_key if api_key uri += address_fragment uri += '&startblock=' + startblock.to_s if startblock uri += '&endblock=' + endblock.to_s if endblock uri += '&blocktype=' + blocktype if blocktype uri += '&txhash=' + txhash if txhash uri += '&blockno=' + blockno.to_s if blockno uri += '&offset=' + offset.to_s if offset uri += '&sort=' + sort if sort uri += '&page=' + page.to_s if page uri += '&tag=' + tag if tag @base + uri end |