Class: RippleRest::Trustlines

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ripple-rest/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Trustlines

Returns a new instance of Trustlines.



181
182
183
# File 'lib/ripple-rest/helpers.rb', line 181

def initialize data
  @data = data
end

Instance Attribute Details

#accountAccount

Returns:



179
180
181
# File 'lib/ripple-rest/helpers.rb', line 179

def 
  @account
end

Instance Method Details

#add(obj, allow_rippling = true) ⇒ Object

Add trustline

Parameters:

  • obj (String, Hash)

    Either a string representation of trustline limit, Hash containing value, currency, counterparty or a string form value/currency/counterparty.

  • allow_rippling (Boolean) (defaults to: true)

    See [here](ripple.com/wiki/No_Ripple) for details

Raises:

  • (ArgumentError)

    if secret is missing from the Account object

  • (RippleRestError)

    if RippleRest server returns an error

  • (ProtocolError)

    if protocol is wrong or network is down



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/ripple-rest/helpers.rb', line 196

def add obj, allow_rippling = true
  raise ArgumentError.new("Account is missing.") unless 
  .require_secret
  
  hash = {}
  hash["allow_rippling"] = allow_rippling
  hash["secret"] = .secret
  
  if obj.is_a? String
    hash["trustline"] = { "limit" => obj }
  else
    hash["trustline"] = obj.to_hash
  end
  
  RippleRest.post "v1/accounts/#{.address}/trustlines", hash
end

#each(*args, &block) ⇒ Object

Use with Enumerable



186
187
188
# File 'lib/ripple-rest/helpers.rb', line 186

def each *args, &block
  @data.each *args, &block
end