class Ryp::Content
Constants
- BTC_ADDRESS_REGEX
- BTC_TRANSACTION_REGEX
- ETH_ADDRESS_REGEX
- ETH_TRANSACTION_REGEX
- MATCHERS
Attributes
data[R]
network[R]
type[R]
value[R]
Public Class Methods
determine_content(data, options = {})
click to toggle source
Allow passing { network: 'n' } to specify a network
# File lib/ryp/content.rb, line 35 def self.determine_content(data, options = {}) specified_network = options[:network] && options[:network].downcase.to_sym puts "Determining Content: #{[data, options].inspect}" if options[:verbose] MATCHERS.each_pair do |network, matchers| next if specified_network && specified_network != network matchers.each_pair do |type, expression| return [network, type] if data =~ expression end end [specified_network || :unknown, :unknown] end
discover(data, options = {})
click to toggle source
# File lib/ryp/content.rb, line 28 def self.discover(data, options = {}) value, network, type = *[data, determine_content(data, options)].flatten new(type: type, network: network, value: data) end
new(type:, network:, value:)
click to toggle source
# File lib/ryp/content.rb, line 22 def initialize(type:, network:, value:) @type = type @network = network @value = value end
Public Instance Methods
client()
click to toggle source
# File lib/ryp/content.rb, line 57 def client @client ||= Ryp::Client.new(network) end
fetch_data!()
click to toggle source
# File lib/ryp/content.rb, line 50 def fetch_data! raise Ryp::UnknownContentType, 'Unkown Content Type' if type == :unknown @data = client.send(type, self) rescue Ryp::BadResponseError => e puts e end