class Viewport < ActiveRecord::Base
  validates_presence_of :width

  belongs_to :project
  validates_presence_of :project

  # @return [String]
  def to_s
    [width, height].join('x')
  end

  # @return [Integer]
  def height
    if width < 960
      width * 2
    else
      (width * 0.75).round # 16:12
    end
  end
end

# A Viewport represents the height and width of the screen when capturing a
# Snapshot for a Url.
class Viewport < ActiveRecord::Base
  validates :width, presence: true

  belongs_to :project
  validates :project, presence: true

  # @return [String]
  def to_s
    [width, height].join('x')
  end

  # @return [Integer]
  def height
    if width < 960
      width * 2
    else
      (width * 0.75).round # 16:12
    end
  end
end

Use the new "sexy" validations in Viewport
Use the new "sexy" validations in Viewport

As pointed out by Rubocop. Also, this commit adds a top-level class
documentation comment to this class.

Change-Id: I4e4cea055c2c2284b0d742bea3ceb9ff285fa71c
