module Thinreports::Core::Shape::Manager::Target
Attributes
manager[R]
Public Instance Methods
[](id)
click to toggle source
@example
page[:text_block].style(:bold, true) page[:rect].style(:border_color, 'red') page[:list] # => Error: UnknownItemId page[:unknown_id] # => Error: UnknownItemId
@param [String, Symbol] id @return [Thinreports::Core::Shape::Base::Interface]
# File lib/thinreports/core/shape/manager/target.rb, line 47 def [](id) item(id) end
[]=(id, value)
click to toggle source
@example
page[:text_block] = 'Title' page[:image_block] = '/path/to/image.png' page[:list] = 'value' # => Error: UnknownItemId page[:ellipse] = 'value' # => Error: NoMethodError #value page[:unknown_id] = 'value' # => Error: UnknownItemId
@param [String, Symbol] id @param [Object] value
# File lib/thinreports/core/shape/manager/target.rb, line 59 def []=(id, value) item(id).value = value end
item(id, &block)
click to toggle source
@example
item(:title).value('Title').style(:fill, 'red') item(:title) do value('Title') style(:fill, 'red') end item(:title) do |t| t.value('Title') t.style(:fill, 'red') end item(:list) # => Error: UnknownItemId item(:unknown_id) # => Error: UnknownItemId
@param [String, Symbol] id @yield [item,] @yieldparam [Thinreports::Core::Shape::Base::Interface] item @raise [Thinreports::Errors::UnknownItemId] @return [Thinreports::Core::Shape::Base::Interface]
# File lib/thinreports/core/shape/manager/target.rb, line 31 def item(id, &block) shape = find_item(id, except: Core::Shape::List::TYPE_NAME) raise Thinreports::Errors::UnknownItemId, id unless shape call_block_in(shape, &block) end
item_exists?(id)
click to toggle source
@param [Symbol, String] id @return [Boolean]
# File lib/thinreports/core/shape/manager/target.rb, line 73 def item_exists?(id) !manager.find_format(id).nil? end
Also aliased as: exists?
list(id = nil, &block)
click to toggle source
@example
report.list.add_row do |row| row.item(:price).value(1000) end report.list(:list_id) # => List report.list(:text_block_id) # => raises UnknownItemId
@see item
# File lib/thinreports/core/shape/manager/target.rb, line 86 def list(id = nil, &block) shape = find_item(id ||= :default, only: Core::Shape::List::TYPE_NAME) raise Thinreports::Errors::UnknownItemId.new(id, 'List') unless shape manager.lists[id.to_sym] ||= shape call_block_in(shape, &block) end
values(item_values)
click to toggle source
@example
page.values text_block: 'value', image_block: '/path/to/image.png'
@param [Hash] item_values
# File lib/thinreports/core/shape/manager/target.rb, line 67 def values(item_values) item_values.each { |id, val| item(id).value(val) } end
Private Instance Methods
find_item(id, limit = {})
click to toggle source
@see Thinreports::Core::Shape::Manager::Internal#find_item
# File lib/thinreports/core/shape/manager/target.rb, line 105 def find_item(id, limit = {}) manager.find_item(id, limit) end
initialize_manager(format, &block)
click to toggle source
@param format (see Thinreports::Core::Shape::Manager::Internal#initialize) @yield [format] Handler for initialize item. @yieldparam [Thinreports::Core::Shape::Basic::Format] format
# File lib/thinreports/core/shape/manager/target.rb, line 100 def initialize_manager(format, &block) @manager = Manager::Internal.new(format, block) end