Sha256: f96477f6cdff13616ad1298b20a90944e5f451ebc03e4f667f3d03f594cd1f0e

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

class PSD
  class Layer
    module Helpers
      # Does this layer represent the start of a folder section?
      def folder?
        if info.has_key?(:section_divider)
          info[:section_divider].is_folder
        elsif info.has_key?(:nested_section_divider)
          info[:nested_section_divider].is_folder
        else
          name == "<Layer group>"
        end
      end

      # Does this layer represent the end of a folder section?
      def folder_end?
        if info.has_key?(:section_divider)
          info[:section_divider].is_hidden
        elsif info.has_key?(:nested_section_divider)
          info[:nested_section_divider].is_hidden
        else
          name == "</Layer group>"
        end
      end

      # Is this layer visible?
      def visible?
        @visible
      end

      # Is this layer hidden?
      def hidden?
        !@visible
      end

      # Helper that exports the text data in this layer, if any.
      def text
        return nil unless info[:type]
        info[:type].to_hash
      end

      def layer_type
        return 'normal' unless info.has_key?(:section_divider)
        info[:section_divider].layer_type
      end

      def fill_opacity
        return 255 unless info.has_key?(:fill_opacity)
        info[:fill_opacity].enabled
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
psd-1.4.5 lib/psd/layer/helpers.rb
psd-1.4.4 lib/psd/layer/helpers.rb
psd-1.4.3 lib/psd/layer/helpers.rb
psd-1.4.2 lib/psd/layer/helpers.rb
psd-1.4.1 lib/psd/layer/helpers.rb
psd-1.4.0 lib/psd/layer/helpers.rb