class PhotoClass
def initialize(media)
@fibs = []
@media = media
@fib = fib(media)
end
def read
@fib.resume @media
end
private
def fib(media)
Fiber.new do |media|
loop do
stop = true
(0..media.length).each do |index|
result = fiber_inner(index).resume media[index].stock_photos if media[index]
unless result.nil?
stop = false
Fiber.yield ({ :index => index, :title => { :group => media[index].title, :image => media[index].stock_photos[result].title }, :url => media[index].stock_photos[result].image.url })
end
end
Fiber.yield nil if stop
end
end
end
protected
def fiber_inner(num)
return @fibs[num] if @fibs[num]
@fibs[num] = Fiber.new do |content|
content.each_with_index do |(image),index|
Fiber.yield index
end
loop do Fiber.yield nil end
end
end
end
<% loop do %>
<% image = @photo.read %>
<% break if image.nil? %>
<div class="portfolio-box cm<%= image[:index] %>-design">
<div class="portfolio-box-container work">
<img src="<%= image[:url] %>" alt="" data-at2x="<%= image[:url] %>">
<div class="portfolio-box-text">
<h3><%= image[:title][:group] %></h3>
<p>Краткое описание картинки изобра.</p>
</div>
<div class="work-bottom">
<a class="big-link-2 view-work" href="<%= image[:url]%>"><span class="icon_search"></span></a>
<a class="big-link-2" href="/complectation/index"><span class="icon_link"></span></a>
</div>
</div>
</div>
<% end %>
class String
def is_wtf_string?
self == 'wtf'
end
end
a = 'wtf'
p a.is_wtf_string? #=> true
# ./ExtStandartClass.rb
module ExtString
def is_wtf_string?
self == 'wtf'
end
end
module ExtFixnum
def squared
self*self
end
end
# добавим расширенные методы
class String; include ExtString; end
class Fixnum; include ExtFixnum; end
# ./SomeCode.rb
# include 'ExtStandartClass.rb'
# ...
a = 'wtf'
p a.is_wtf_string? #=> true
# ...
# где нибудь в коде если приспичит узнать что откуда
p a.method(:to_s)
p a.method(:is_wtf_string?)
# аналогично
b = 5
p b.squared
p b.method(:to_s)
p b.method(:squared)
heroes = [
new Hero(1, 'Windstorm', 'Really Smart', 'optional'),
new Hero(13, 'Bombasto', 'Super Bad Man' ),
];
hero: Hero = {
id: 1,
name: 'Windstorm',
power: 'Black T'
};
app/app.component.ts(32,3): error TS2322: Type '{ id: number; name: string; power: string; }' is not assignable to type 'Hero'.
Property 'alterEgo' is missing in type '{ id: number; name: string; power: string; }'
heroes[4] = new Hero(1, 'BatCat','Old cat','optional');
app/app.component.ts(26,9): error TS1005: '=' expected.
validates :price, numericality: {greater_than_or_equal_to: 0.01}
must be greater than or equal to 0.01