<commit_before>module Jdoc
  class Property
    attr_reader :name

    # @param name [String]
    # @param schema [JsonSchema::Schema]
    def initialize(name: nil, schema: nil)
      @name = name
      @schema = schema
    end

    # @return [Hash] Key-Value pair of metadata of this property
    def options
      {
        Example: example,
        Type: type,
        Format: format,
        Patern: pattern,
        ReadOnly: read_only,
      }.reject {|key, value| value.nil? }
    end

    # @return [String, nil] Description text, defined in description property
    def description
      @schema.description
    end

    # @return [String, nil] Example value, defined in example property
    def example
      if str = @schema.data["example"]
        "`#{str}`"
      end
    end

    # @return [String, nil] Pattern constraint, defined in pattern property
    def pattern
      if str = @schema.pattern
        "`#{str}`"
      end
    end

    # @return [Stirng, nil] Format constraint, defined in format property
    def format
      @schema.format
    end

    # @return [true, nil] True if readOnly property is defined and it's true
    def read_only
      true if @schema.read_only == true
    end

    # @return [String, nil] Possible types defined in type property
    def type
      if @schema.type
        @schema.type.join(", ")
      end
    end<commit_msg>Show example value in Properties section, when example value is false<commit_after>module Jdoc
  class Property
    attr_reader :name

    # @param name [String]
    # @param schema [JsonSchema::Schema]
    def initialize(name: nil, schema: nil)
      @name = name
      @schema = schema
    end

    # @return [Hash] Key-Value pair of metadata of this property
    def options
      {
        Example: example,
        Type: type,
        Format: format,
        Patern: pattern,
        ReadOnly: read_only,
      }.reject {|key, value| value.nil? }
    end

    # @return [String, nil] Description text, defined in description property
    def description
      @schema.description
    end

    # @return [String, nil] Example value, defined in example property
    def example
      return if (str = @schema.data["example"]).nil?
      "`#{str}`"
    end

    # @return [String, nil] Pattern constraint, defined in pattern property
    def pattern
      if str = @schema.pattern
        "`#{str}`"
      end
    end

    # @return [Stirng, nil] Format constraint, defined in format property
    def format
      @schema.format
    end

    # @return [true, nil] True if readOnly property is defined and it's true
    def read_only
      true if @schema.read_only == true
    end

    # @return [String, nil] Possible types defined in type property
    def type
      if @schema.type
        @schema.type.join(", ")
      end
    end
{'fraction_non_alphanumeric': 0.0906183368869936, 'fraction_numerical': 0.0, 'mean_word_length': 2.288551401869159, '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': '5732051', 'n_tokens_mistral': 806, 'n_tokens_neox': 789, 'n_words': 295}