<commit_before>module Mangdown
  class MDHash
    include Equality

		def initialize(options = {})
      @properties = Properties.new(
        options[:uri], options[:site], nil, options[:name]
      )

      @hash = {}
      [:uri, :name].each {|key| @hash[key] = options.fetch(key)}
      @hash[:uri]  = Mangdown::Uri.new(@hash[:uri])
      @hash[:site] = @properties.type
		end

		# explicit conversion to manga 
    def to_manga
      if @properties.is_manga?
        Manga.new(uri, name)
      else
        raise NoMethodError, 'This is not a known manga type'
      end
    end

		# explicit conversion to chapter 
		def to_chapter
      if @properties.is_chapter?
        Chapter.new(uri, name)
      else
        raise NoMethodError, 'This is not a known chapter type'
      end
		end

		# explicit conversion to page 
 	  def to_page 
      if @properties.is_page?
        Page.new(uri, name)
      else
        raise NoMethodError, 'This is not a known page type'
      end
		end	

    # name reader
    def name
      @hash[:name]
    end

    # uri reader
    def uri
      @hash[:uri]
    end

    # name writer
    def name=(other)
      @hash[:name] = other
    end

    # uri writer
    def uri=(other)
      @hash[:uri] = other
    end

    def [](key)
      @hash[key]
    end

    def to_hash
      @hash
    end

    def inspect
      to_hash.to_s
    end
    alias_method :to_s, :inspect

    def type
      @properties.type
    end
  end
end
<commit_msg>refactored mangdown hash<commit_after>module Mangdown
  class MDHash
    include Equality

		def initialize(options = {})
      uri = options.fetch(:uri)
      name = options[:name]
      site = options[:site]
      @properties = Properties.new(uri, site, nil, name)

      @hash = {}
      @hash[:name] = name
      @hash[:uri] = Mangdown::Uri.new(uri)
      @hash[:site] = @properties.type
		end

		# explicit conversion to manga 
    def to_manga
      if @properties.is_manga?
        Manga.new(uri, name)
      else
        raise NoMethodError, 'This is not a known manga type'
      end
    end

		# explicit conversion to chapter 
		def to_chapter
      if @properties.is_chapter?
        Chapter.new(uri, name)
      else
        raise NoMethodError, 'This is not a known chapter type'
      end
		end

		# explicit conversion to page 
 	  def to_page 
      if @properties.is_page?
        Page.new(uri, name)
      else
        raise NoMethodError, 'This is not a known page type'
      end
		end	

    # name reader
    def name
      @hash[:name]
    end

    # uri reader
    def uri
      @hash[:uri]
    end

    # name writer
    def name=(other)
      @hash[:name] = other
    end

    # uri writer
    def uri=(other)
      @hash[:uri] = other
    end

    def [](key)
      @hash[key]
    end

    def to_hash
      @hash
    end

    def inspect
      to_hash.to_s
    end
    alias_method :to_s, :inspect

    def type
      @properties.type
    end
  end
end
{'fraction_non_alphanumeric': 0.09201623815967523, 'fraction_numerical': 0.0, 'mean_word_length': 1.9219367588932805, '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': '3490845', 'n_tokens_mistral': 999, 'n_tokens_neox': 934, 'n_words': 280}