class ReadingLevelDataProcessor

Attributes

json_data[R]
parsed_data[R]

Public Instance Methods

data(json_data) click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 4
def data(json_data)
  @json_data   = json_data
  @parsed_data = parse_data
  process
end

Private Instance Methods

ari() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 31
def ari
  parsed_data.fetch('ari') { 0 }
end
coleman_liau_reading_level() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 35
def coleman_liau_reading_level
  parsed_data.fetch('coleman-liau') { 0 }
end
composite() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 27
def composite
  parsed_data.fetch('composite') { 0 }
end
flesch_kincaid_reading_level() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 39
def flesch_kincaid_reading_level
  parsed_data.fetch('flesch-kincaid') { 0 }
end
gunning_fog_reading_level() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 43
def gunning_fog_reading_level
  parsed_data.fetch('gunning-fog') { 0 }
end
parse_data() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 23
def parse_data
  JSON.parse(json_data).fetch('data') { {} }
end
process() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 12
def process
  {
    composite_reading_level:      composite,
    ari_reading_level:            ari,
    coleman_liau_reading_level:   coleman_liau_reading_level,
    flesch_kincaid_reading_level: flesch_kincaid_reading_level,
    gunning_fog_reading_level:    gunning_fog_reading_level,
    smog_reading_level:           smog_reading_level
  }
end
smog_reading_level() click to toggle source
# File lib/contentar/data_processors/reading_level.rb, line 47
def smog_reading_level
  parsed_data.fetch('smog') { 0 }
end