Class: Ordinals::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/ordbase/tool.rb

Class Method Summary collapse

Class Method Details

.do_convert_images(slug) ⇒ Object



100
101
102
103
104
105
# File 'lib/ordbase/tool.rb', line 100

def self.do_convert_images( slug )
  puts "==> convert images for collection >#{slug}<..."

  col = Collection.new( slug )
  col.convert_images
end

.do_download_images(slug) ⇒ Object



92
93
94
95
96
97
# File 'lib/ordbase/tool.rb', line 92

def self.do_download_images( slug )
  puts "==> download images for collection >#{slug}<..."

  col = Collection.new( slug )
  col.download_images
end

.do_download_meta(slug) ⇒ Object



85
86
87
88
89
90
# File 'lib/ordbase/tool.rb', line 85

def self.do_download_meta( slug )
  puts "==> download meta for collection >#{slug}<..."

  col = Collection.new( slug )
  col.download_meta
end

.do_dump_stats(slug) ⇒ Object



78
79
80
81
82
83
# File 'lib/ordbase/tool.rb', line 78

def self.do_dump_stats( slug )
  puts "==> dump inscription stats for collection >#{slug}<..."

  col = Collection.new( slug )
  col.dump_stats
end

.do_fix_images(slug) ⇒ Object



107
108
109
110
111
112
# File 'lib/ordbase/tool.rb', line 107

def self.do_fix_images( slug )
  puts "==> fix images for collection >#{slug}<..."

  col = Collection.new( slug )
  col.fix_images
end

.do_make_composite(slug, limit: nil) ⇒ Object



122
123
124
125
126
127
# File 'lib/ordbase/tool.rb', line 122

def self.do_make_composite( slug, limit: nil )
  puts "==> make composite for collection >#{slug}<..."

  col = Collection.new( slug )
  col.make_composite( limit: limit )
end

.do_pixelate(slug) ⇒ Object



115
116
117
118
119
120
# File 'lib/ordbase/tool.rb', line 115

def self.do_pixelate( slug )
  puts "==> downsample / pixelate images for collection >#{slug}<..."

  col = Collection.new( slug )
  col.pixelate
end

.main(args = ARGV) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ordbase/tool.rb', line 4

def self.main( args=ARGV )
  puts "==> welcome to the ordbase tool with args:"
  pp args

  options = {
            }

  parser = OptionParser.new do |opts|
    opts.on( "--doge", "--dogecoin", "Use Dogecoin / DOGE") do
      ## switch to doge
      Ordinals.config.chain = :doge
    end
    opts.on( "--ltc", "--litecoin", "Use Litecoin / LTC") do
        ## switch to ltc
        Ordinals.config.chain = :ltc
    end
    opts.on( "--btc", "--bitcoin", "Use Bitcoin / BTC") do
        ## switch to btc  (default)
        Ordinals.config.chain = :btc
    end

    opts.on("--limit NUM", Integer,
           "Limit collection (default: ∞)") do |num|
       options[ :limit]  = num
    end

    opts.on("-h", "--help", "Prints this help") do
      puts opts
      exit
    end
  end

  parser.parse!( args )
  puts "options:"
  pp options

  puts "args:"
  pp args

  if args.size < 1
    puts "!! ERROR - no collection found - use <collection> <command>..."
    puts ""
    exit
  end

  slug             = args[0]
  command          = args[1] || 'image'

  if ['m', 'meta'].include?( command )
    do_download_meta( slug )
  elsif ['stat', 'stats'].include?( command )
    do_dump_stats( slug )
  elsif ['i','img', 'image'].include?( command )
    do_download_images( slug )
  elsif ['conv','convert'].include?( command )
    do_convert_images( slug )
  elsif ['fix'].include?( command )
    do_fix_images( slug )
  elsif ['px','pix', 'pixelate' ].include?( command )
    do_pixelate( slug )
  elsif ['comp','composite' ].include?( command )
    if options.has_key?( :limit )
      do_make_composite( slug, limit: options[:limit] )
    else
      do_make_composite( slug )
    end
  else
    puts "!! ERROR - unknown command >#{command}<, sorry"
  end

  puts "bye"
end