Sha256: 388ae9c967dd38668e1f44ee2f6e090565cf23d0e6cd0e8e53026c5a6706ac34

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

require 'skiplan_client/attribute_helper'

class Zone

  include AttributeHelper

  def initialize(attributes)
    normalized_attrs = attributes.dup
    normalized_attrs['REMONTEE'] = [normalized_attrs['REMONTEE']] if normalized_attrs['REMONTEE'].is_a?(Hash)
    normalized_attrs['PISTE'] = [normalized_attrs['PISTE']] if normalized_attrs['PISTE'].is_a?(Hash)
    normalized_attrs['Liaison'] = [normalized_attrs['Liaison']] if normalized_attrs['Liaison'].is_a?(Hash)
    self.attributes = normalized_attrs
  end

  def name
    @nom
  end

  def skilifts
    @REMONTEE
  end

  def slopes
    @PISTE
  end

  def connections
    @Liaison
  end

  def ratio(array_field = [])
    open_entries = array_field.select {|r| r['etat'] == 'O'}
    "#{open_entries.length}/#{array_field.length}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
skiplan_client-0.2.4 lib/skiplan_client/zone.rb
skiplan_client-0.2.3 lib/skiplan_client/zone.rb