Class: Pageflow::PositionedFile

Inherits:
Object
  • Object
show all
Defined in:
app/models/pageflow/positioned_file.rb

Direct Known Subclasses

Null

Defined Under Namespace

Classes: Null

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, position_x = nil, position_y = nil) ⇒ PositionedFile

Returns a new instance of PositionedFile.



7
8
9
10
11
# File 'app/models/pageflow/positioned_file.rb', line 7

def initialize(file, position_x = nil, position_y = nil)
  @file = file
  @position_x = position_x.presence || 50
  @position_y = position_y.presence || 50
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'app/models/pageflow/positioned_file.rb', line 3

def file
  @file
end

#position_xObject (readonly)

Returns the value of attribute position_x.



3
4
5
# File 'app/models/pageflow/positioned_file.rb', line 3

def position_x
  @position_x
end

#position_yObject (readonly)

Returns the value of attribute position_y.



3
4
5
# File 'app/models/pageflow/positioned_file.rb', line 3

def position_y
  @position_y
end

Class Method Details

.nullObject



28
29
30
# File 'app/models/pageflow/positioned_file.rb', line 28

def self.null
  Null.new
end

.wrap(file, position_x, position_y) ⇒ Object



24
25
26
# File 'app/models/pageflow/positioned_file.rb', line 24

def self.wrap(file, position_x, position_y)
  file ? new(file, position_x, position_y) : nil
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
16
17
18
# File 'app/models/pageflow/positioned_file.rb', line 13

def ==(other)
  super(other) ||
    other == file ||
    (other.is_a?(PositionedFile) && other.file == file) ||
    (other.class == file.class && other.id == file.id)
end

#to_modelObject



20
21
22
# File 'app/models/pageflow/positioned_file.rb', line 20

def to_model
  file
end