class RayyanFormats::Source

Attributes

attachment[R]
name[R]

Public Class Methods

new(_name, _attachment = nil) click to toggle source
# File lib/rayyan-formats-core/source.rb, line 21
def initialize(_name, _attachment = nil)
  self.name = _name
  self.attachment = _attachment
end

Public Instance Methods

attachment=(value) click to toggle source
# File lib/rayyan-formats-core/source.rb, line 10
def attachment=(value)
  @attachment = if value.nil?
    File.open(self.name)
  else
    [:size, :read, :close].each do |message|
      raise "Invalid attachment, must respond to :size, :read and :close" unless value.respond_to?(message)
    end
    value
  end
end
name=(value) click to toggle source
# File lib/rayyan-formats-core/source.rb, line 5
def name=(value)
  raise "Invalid name: #{value}, must end with '.' then extension" unless value =~ /\..+/
  @name = value
end