<commit_before># encoding: UTF-8

require "beerbelly/client/error"
require "beerbelly/client/resources/resource"
require "beerbelly/client/resources/beer"
require "beerbelly/client/resources/brewery"

module Beerbelly
  class Client
    class Response
      extend Forwardable

      attr_reader :page, :pages, :total, :objects

      def_delegators :@objects, :[], :length

      def initialize(response, type)
        return Beerbelly::Client::Error.new(response.code) if response.code != 200

        case type
        when 'beers'
          @objects = response[type].collect { |beer| Beerbelly::Beer.build beer }
        when 'beer'
          @objects = [ Beerbelly::Beer.build(response.to_hash) ]
        when 'breweries'
          @objects = response[type].collect { |beer| Beerbelly::Brewery.build beer }
        when 'brewery'
          @objects = [ Beerbelly::Brewery.build(response.to_hash) ]
        end
      end
    end
  end
end
<commit_msg>Added more delegate methods<commit_after># encoding: UTF-8

require "beerbelly/client/error"
require "beerbelly/client/resources/resource"
require "beerbelly/client/resources/beer"
require "beerbelly/client/resources/brewery"

module Beerbelly
  class Client
    class Response
      extend Forwardable

      attr_reader :page, :pages, :total, :objects

      def_delegators :@objects, :[], :length, :first, :last

      def initialize(response, type)
        return Beerbelly::Client::Error.new(response.code) if response.code != 200

        case type
        when 'beers'
          @objects = response[type].collect { |beer| Beerbelly::Beer.build beer }
        when 'beer'
          @objects = [ Beerbelly::Beer.build(response.to_hash) ]
        when 'breweries'
          @objects = response[type].collect { |beer| Beerbelly::Brewery.build beer }
        when 'brewery'
          @objects = [ Beerbelly::Brewery.build(response.to_hash) ]
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.111397627643115, 'fraction_numerical': 0.0041258380608561115, 'mean_word_length': 2.911290322580645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6179379', 'n_tokens_mistral': 632, 'n_tokens_neox': 603, 'n_words': 133}