Sha256: 2d1a562f6b347e4a28d516e5fdf2ced15d94c405ef502f70504a0dc638afa4c1

Contents?: true

Size: 2 KB

Versions: 3

Compression:

Stored size: 2 KB

Contents

# Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
# This file is part of Germinal.
#
# Germinal 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
# any later version.
#
# Germinal 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 Germinal.  If not, see <http://www.gnu.org/licenses/>.

module GerminalStyleProperties
  def generate_string_rw_property(name, args)
    GLib::Param::String.new(name.downcase,
                            name.capitalize,
                            name.upcase,
                            args,
                            GLib::Param::READABLE |
                            GLib::Param::WRITABLE)
  end

  def generate_int_rw_property(name, args)
    GLib::Param::Int.new(name.downcase,
                         name.capitalize,
                         name.upcase,
                         *args,
                         GLib::Param::READABLE |
                         GLib::Param::WRITABLE)
  end

  def generate_boxed_rw_property(name, args)
    GLib::Param::Boxed.new(name.downcase,
                           name.capitalize,
                           name.upcase,
                           args,
                           GLib::Param::READABLE |
                           GLib::Param::WRITABLE)
  end

  def generate_rw_property(type, name, args)
    type = type.to_s.downcase
    method_name = "generate_#{type}_rw_property"
    return false unless methods.include?(method_name.to_sym)
    method(method_name.to_sym).call(name, args)
  end

  def install_style(type, name, args)
    property = generate_rw_property(type, name, args)
    install_style_property(property) if property
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Germinal-1.3.2 lib/style_properties.rb
Germinal-1.3.1 lib/style_properties.rb
Germinal-1.3.0 lib/style_properties.rb