Class: Dropzone::Listing

Inherits:
RecordBase show all
Includes:
StateAccumulator
Defined in:
lib/dropzone/listing.rb

Defined Under Namespace

Classes: Validator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StateAccumulator

#blockchain, included, #messages

Methods inherited from RecordBase

#blockchain, #errors, #valid?

Constructor Details

#initialize(txid) ⇒ Listing

Returns a new instance of Listing.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dropzone/listing.rb', line 11

def initialize(txid)
  @txid = txid

  item = Item.find txid
  @create_item = item if item && item.valid? && item.message_type == 'ITCRTE'

  if create_item
    attrs_from create_item

    messages(start_block: create_item.block_height).reverse.each{ |item| 
      attrs_from item if item.create_txid == txid}
  end
end

Instance Attribute Details

#create_itemObject (readonly)

Returns the value of attribute create_item.



5
6
7
# File 'lib/dropzone/listing.rb', line 5

def create_item
  @create_item
end

#txidObject (readonly)

Returns the value of attribute txid.



5
6
7
# File 'lib/dropzone/listing.rb', line 5

def txid
  @txid
end

Instance Method Details

#addrObject



33
# File 'lib/dropzone/listing.rb', line 33

def addr; from_create :sender_addr; end

#expiration_atObject



29
30
31
# File 'lib/dropzone/listing.rb', line 29

def expiration_at
  create_item.block_height+expiration_in
end

#found?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/dropzone/listing.rb', line 25

def found?
  !@create_item.nil?
end

#latitudeObject



34
# File 'lib/dropzone/listing.rb', line 34

def latitude; from_create :latitude; end

#longitudeObject



35
# File 'lib/dropzone/listing.rb', line 35

def longitude; from_create :longitude; end

#radiusObject



36
# File 'lib/dropzone/listing.rb', line 36

def radius; from_create :radius; end

#seller_profileObject



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

def seller_profile
  @seller_profile ||= SellerProfile.new addr if addr
end