Class: Alf::Shell::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/alf/shell/command/metadata.rb

Instance Method Summary collapse

Instance Method Details

#compile(argv) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/alf/shell/command/metadata.rb', line 26

def compile(argv)
  op = operand(argv.shift)
  op.heading
  op
rescue Alf::NotSupportedError
  op = op.to_relation
  op
end

#run(argv, requester) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/alf/shell/command/metadata.rb', line 13

def run(argv, requester)
  # set requester and parse options
  @requester = requester
  argv = parse_options(argv, :split)

  operand = compile(argv)
  keys    = operand.keys.to_a.map{|k| k.to_a }
  heading = Relation(operand.heading.to_hash.each_pair.map{|k,v|
    {attribute: k, type: v.to_s}
  })
  puts Relation({heading: heading, keys: keys})
end