Module: Ssource::Source::Factory

Defined in:
lib/ssource/source/factory.rb

Class Method Summary collapse

Class Method Details

.build(json) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/ssource/source/factory.rb', line 6

def self.build(json)
  const = case json['kind']
          when ->(kind) { kind.include? 'decl.var' } then Variable
          when ->(kind) { kind.include? 'decl.class' } then Klass
          when ->(kind) { kind.include? 'decl.function' } then Method
          when ->(kind) { kind.include? 'decl.extension' } then Extension
          else Element
          end
  const.new json
end