Class: Bitcoin::Namecoin::Storage::Models::Name
- Inherits:
-
Object
- Object
- Bitcoin::Namecoin::Storage::Models::Name
- Defined in:
- lib/bitcoin/namecoin.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#txout_id ⇒ Object
readonly
Returns the value of attribute txout_id.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #as_json(opts = {}) ⇒ Object
- #expires_in ⇒ Object
- #get_address ⇒ Object
- #get_block ⇒ Object
- #get_tx ⇒ Object
- #get_txout ⇒ Object
-
#initialize(store, data) ⇒ Name
constructor
A new instance of Name.
Constructor Details
#initialize(store, data) ⇒ Name
Returns a new instance of Name.
237 238 239 240 241 242 243 |
# File 'lib/bitcoin/namecoin.rb', line 237 def initialize store, data @store = store @txout_id = data[:txout_id] @hash = data[:hash] @name = data[:name] @value = data[:value] end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
235 236 237 |
# File 'lib/bitcoin/namecoin.rb', line 235 def hash @hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
235 236 237 |
# File 'lib/bitcoin/namecoin.rb', line 235 def name @name end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
235 236 237 |
# File 'lib/bitcoin/namecoin.rb', line 235 def store @store end |
#txout_id ⇒ Object (readonly)
Returns the value of attribute txout_id.
235 236 237 |
# File 'lib/bitcoin/namecoin.rb', line 235 def txout_id @txout_id end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
235 236 237 |
# File 'lib/bitcoin/namecoin.rb', line 235 def value @value end |
Instance Method Details
#as_json(opts = {}) ⇒ Object
269 270 271 272 |
# File 'lib/bitcoin/namecoin.rb', line 269 def as_json(opts = {}) { name: @name, value: @value, txid: get_tx.hash, address: get_address, expires_in: expires_in } end |
#expires_in ⇒ Object
265 266 267 |
# File 'lib/bitcoin/namecoin.rb', line 265 def expires_in Bitcoin::Namecoin::EXPIRATION_DEPTH - (@store.get_depth - get_block.depth) rescue nil end |
#get_address ⇒ Object
253 254 255 |
# File 'lib/bitcoin/namecoin.rb', line 253 def get_address get_txout.get_address end |
#get_block ⇒ Object
261 262 263 |
# File 'lib/bitcoin/namecoin.rb', line 261 def get_block get_tx.get_block rescue nil end |
#get_tx ⇒ Object
257 258 259 |
# File 'lib/bitcoin/namecoin.rb', line 257 def get_tx get_txout.get_tx rescue nil end |
#get_txout ⇒ Object
245 246 247 248 249 250 251 |
# File 'lib/bitcoin/namecoin.rb', line 245 def get_txout if @txout_id.is_a?(Array) @store.get_tx(@txout_id[0]).out[@txout_id[1]] else @store.get_txout_by_id(@txout_id) end end |