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
- #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.
- #to_json(opts = {}) ⇒ Object
Constructor Details
#initialize(store, data) ⇒ Name
Returns a new instance of Name.
236 237 238 239 240 241 242 |
# File 'lib/bitcoin/namecoin.rb', line 236 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.
234 235 236 |
# File 'lib/bitcoin/namecoin.rb', line 234 def hash @hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
234 235 236 |
# File 'lib/bitcoin/namecoin.rb', line 234 def name @name end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
234 235 236 |
# File 'lib/bitcoin/namecoin.rb', line 234 def store @store end |
#txout_id ⇒ Object (readonly)
Returns the value of attribute txout_id.
234 235 236 |
# File 'lib/bitcoin/namecoin.rb', line 234 def txout_id @txout_id end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
234 235 236 |
# File 'lib/bitcoin/namecoin.rb', line 234 def value @value end |
Instance Method Details
#expires_in ⇒ Object
264 265 266 |
# File 'lib/bitcoin/namecoin.rb', line 264 def expires_in Namecoin::EXPIRATION_DEPTH - (@store.get_depth - get_block.depth) rescue nil end |
#get_address ⇒ Object
252 253 254 |
# File 'lib/bitcoin/namecoin.rb', line 252 def get_address get_txout.get_address end |
#get_block ⇒ Object
260 261 262 |
# File 'lib/bitcoin/namecoin.rb', line 260 def get_block get_tx.get_block rescue nil end |
#get_tx ⇒ Object
256 257 258 |
# File 'lib/bitcoin/namecoin.rb', line 256 def get_tx get_txout.get_tx rescue nil end |
#get_txout ⇒ Object
244 245 246 247 248 249 250 |
# File 'lib/bitcoin/namecoin.rb', line 244 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 |
#to_json(opts = {}) ⇒ Object
268 269 270 271 |
# File 'lib/bitcoin/namecoin.rb', line 268 def to_json(opts = {}) JSON.pretty_generate({ name: @name, value: @value, txid: get_tx.hash, address: get_address, expires_in: expires_in }, opts) end |