Sha256: 5e5a59811cf2c7a4e90032476d91255afed8d466fe994a3d29d2636b2b889648

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Moblues
  module Reader
    class Type
      def map_type_str(type_str)
        case type_str
        when 'String'
          :string
        when 'Integer 16', 'Integer 32', 'Integer 64', 'Boolean'
          :number
        when 'Date'
          :date
        when 'Binary'
          :data
        when 'Transformable'
          :id
        else
          raise ArgumentError.new("unknown type #{type_str}")
        end
      end

      def property_type(type)
        case type
        when :string
          'NSString *'
        when :number
          'NSNumber *'
        when :date
          'NSDate *'
        when :data
          'NSData *'
        when :id
          'id '
        else
          raise ArgumentError.new("unknown type #{type}")
        end
      end

      def property_attributes(type)
        case type
        when :string
          %w{nonatomic copy}
        when :number, :date, :data, :id
          %w{nonatomic strong}
        else
          raise ArgumentError.new("unknown type #{type}")
        end
      end

      def relationship_type(relationship)
        if relationship.to_many
          relationship.ordered ? 'NSOrderedSet *' : 'NSSet *'
        else
          relationship.destination_entity + ' *'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
moblues-0.1.0 lib/moblues/reader/type.rb
moblues-0.0.1 lib/moblues/reader/type.rb