Sha256: 737dad0ba4b51e261e1f517bd4384fef2b271849b2989d7f633b3a83b77164c0

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

#--
# gravaty
# rubocop:disable Style/AsciiComments
# © 2013 Marco Bresciani
# rubocop:enable Style/AsciiComments
#
# This file is part of gravaty.
#
# gravaty is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# gravaty is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with gravaty. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-FileCopyrightText: 2013 Marco Bresciani
#
# SPDX-License-Identifier: GPL-3.0-or-later
#++

require_relative '../constants'
require_relative '../utils/raisers'

module Gravaty
  module Parsers
    # This class is an implementation of the Parsable duck type that
    # checks the image size. The only needed parameter is a valid image
    # size.
    #
    # Author:: {Marco Bresciani}[mailto:marcobresciani_1974@libero.it]
    # rubocop:disable Style/AsciiComments
    # Copyright:: Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020  Marco Bresciani
    # rubocop:enable Style/AsciiComments
    # License:: GNU General Public License version 3
    class Pixelsize
      include Utils::Raisers

      # The parsable duck type interface to every parser usage.
      def parse(value = nil)
        raiser_to_i('error.value', value, ALLOWED_SIZES)
        value.nil? ? '' : "s=#{value}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gravaty-11.0.1 lib/gravaty/parsers/pixelsize.rb