Sha256: 3767029fffb5b068becae384479c7e35d3b5032f1bf1214aa4534778e30134ed
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Ruboty module Ragoon class Event include ::Ruboty::Ragoon::Template attr_accessor :date attr_reader :events def initialize(date = Date.today) @date = date self.retrieve end def retrieve @events ||= ::Ragoon::Services::Schedule.new.schedule_get_events(::Ragoon::Services.start_and_end(date)) end def render(private: false) render_template('events', events: format(private), date: self.date) end private def format(private) @events.map { |event| format_event(event, private) } end def format_event(event, private) plan = event[:plan].to_s != '' ? "【#{event[:plan].strip}】" : '' period = if event[:allday] '終日' else "#{format_time(event[:start_at])}〜#{format_time(event[:end_at])}" end if !private && event[:private] title = '予定あり' facilities = '' url = '' else title = event[:title] facilities = event[:facilities].join(', ') url = event[:url] end { plan: plan, period: period, title: title, facilities: facilities, private: event[:private], url: url, } end def format_time(time) if time.to_s == '' '' else Time.parse(time).localtime.strftime('%R') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruboty-ragoon-0.2.0 | lib/ruboty/ragoon/event.rb |