<commit_before>module Metro
  module Models

    #
    # Draws a string of text
    #
    # @example Using the Label in a view file
    #    model: "metro::models::label"
    #
    class Label < Model

      attr_accessor :x, :y, :x_factor, :y_factor, :z_order
      attr_accessor :size, :size, :font_family

      def after_initialize
        @text = ""
        @x_factor = @y_factor = 1.0
        @z_order = 0
        @color = Gosu::Color.new "rgba(255,255,255,1.0)"
        @size = 20
        @font_family = Gosu::default_font_name
      end

      def font
        @font ||= Gosu::Font.new(window, font_family, size)
      end

      def x
        @x || (Game.width/2 - font.text_width(text)/2)
      end

      def y
        @y || (Game.height/2 - font.height/2)
      end

      def bounds
        Bounds.new x, y, x + width, y + height
      end

      def width
        font.text_width(text) * x_factor
      end

      def height
        font.height * y_factor
      end

      def contains?(x,y)
        bounds.contains?(x,y)
      end

      def text
        scene.instance_eval( "\"#{@text}\"" )
      end

      def draw
        label_text = text
        font.draw label_text, x, y, z_order, x_factor, y_factor, color
      end

    end
  end
end<commit_msg>Label able to edit the text on the label<commit_after>module Metro
  module Models

    #
    # Draws a string of text
    #
    # @example Using the Label in a view file
    #    model: "metro::models::label"
    #
    class Label < Model

      attr_accessor :x, :y, :x_factor, :y_factor, :z_order
      attr_accessor :size, :size, :font_family

      def after_initialize
        @text = ""
        @x_factor = @y_factor = 1.0
        @z_order = 0
        @color = Gosu::Color.new "rgba(255,255,255,1.0)"
        @size = 20
        @font_family = Gosu::default_font_name
      end

      def font
        @font ||= Gosu::Font.new(window, font_family, size)
      end

      def x
        @x || (Game.width/2 - font.text_width(text)/2)
      end

      def y
        @y || (Game.height/2 - font.height/2)
      end

      def bounds
        Bounds.new x, y, x + width, y + height
      end

      def width
        font.text_width(text) * x_factor
      end

      def height
        font.height * y_factor
      end

      def contains?(x,y)
        bounds.contains?(x,y)
      end

      def text
        scene.instance_eval( "\"#{@text}\"" )
      end

      attr_writer :text

      def draw
        label_text = text
        font.draw label_text, x, y, z_order, x_factor, y_factor, color
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.10601387818041634, 'fraction_numerical': 0.015420200462606014, 'mean_word_length': 1.703125, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1971885', 'n_tokens_mistral': 923, 'n_tokens_neox': 871, 'n_words': 233}