Class: ProjectDecorator

Inherits:
Draper::Decorator
  • Object
show all
Includes:
Draper::LazyHelpers
Defined in:
app/decorators/project_decorator.rb

Instance Method Summary collapse

Instance Method Details

#display_expires_atObject



40
41
42
# File 'app/decorators/project_decorator.rb', line 40

def display_expires_at
  source.expires_at ? I18n.l(source.expires_at.to_date) : ''
end

#display_goalObject



48
49
50
# File 'app/decorators/project_decorator.rb', line 48

def display_goal
  number_to_currency source.goal
end

#display_image(version = 'project_thumb') ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'app/decorators/project_decorator.rb', line 24

def display_image(version = 'project_thumb' )
  if source.uploaded_image.present?
    source.uploaded_image.send(version).url
  elsif source.video_thumbnail.url.present?
    source.video_thumbnail.send(version).url
  elsif source.video
    source.video.thumbnail_large
  end
end

#display_pledgedObject



44
45
46
# File 'app/decorators/project_decorator.rb', line 44

def display_pledged
  number_to_currency source.pledged
end

#display_progressObject

Method for width of progress bars only



18
19
20
21
22
# File 'app/decorators/project_decorator.rb', line 18

def display_progress
  return 100 if source.successful? || source.progress > 100
  return 8 if source.progress > 0 and source.progress < 8
  source.progress
end

#display_statusObject



9
10
11
12
13
14
15
# File 'app/decorators/project_decorator.rb', line 9

def display_status
  if source.online?
    (source.reached_goal? ? 'reached_goal' : 'not_reached_goal')
  else
    source.state
  end
end

#display_video_embed_urlObject



34
35
36
37
38
# File 'app/decorators/project_decorator.rb', line 34

def display_video_embed_url
  if source.video_embed_url
    "#{source.video_embed_url}?title=0&byline=0&portrait=0&autoplay=0"
  end
end

#progress_barObject



52
53
54
55
56
57
# File 'app/decorators/project_decorator.rb', line 52

def progress_bar
  width = source.progress > 100 ? 100 : source.progress
  (:div, id: :progress_wrapper) do
    (:div, nil, id: :progress, style: "width: #{width}%")
  end
end

#remaining_daysObject



5
6
7
# File 'app/decorators/project_decorator.rb', line 5

def remaining_days
  source.time_to_go[:time]
end

#successful_flagObject



60
61
62
63
64
65
66
67
# File 'app/decorators/project_decorator.rb', line 60

def successful_flag
  return nil unless source.successful?

  (:div, class: [:successful_flag]) do
    image_tag("channels/successful.png")
  end

end