lib/vedeu/api/interface.rb in vedeu-0.1.18 vs lib/vedeu/api/interface.rb in vedeu-0.1.19
- old
+ new
@@ -1,8 +1,11 @@
module Vedeu
module API
+
+ # Provides methods to be used to define interfaces or views.
class Interface < Vedeu::Interface
+
include Helpers
# Define a single line in a view.
#
# @api public
@@ -19,17 +22,19 @@
# line do
# ... some line attributes ...
# end
# end
#
- # @return []
+ # @return [API::Interface]
def line(value = '', &block)
if block_given?
- attributes[:lines] << Line.build(&block)
+ attributes[:lines] << API::Line
+ .build({ parent: self.view_attributes }, &block)
else
- attributes[:lines] << Line.build({ streams: { text: value } })
+ attributes[:lines] << API::Line
+ .build({ streams: { text: value }, parent: self.view_attributes })
end
end
# Use the specified interface; useful for sharing attributes with other
@@ -51,11 +56,11 @@
# @example
# interface 'my_interface' do
# cursor true
# ...
#
- # @return []
+ # @return [API::Interface]
def cursor(value)
unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
fail InvalidSyntax, 'Argument must be `true` or `false` for cursor.'
end
@@ -67,11 +72,11 @@
# screen.
#
# @api public
# @param value [Fixnum|Float]
#
- # @return []
+ # @return [API::Interface]
def delay(value)
attributes[:delay] = value
end
# Define a group for an interface. Interfaces of the same group can be
@@ -84,11 +89,11 @@
# @example
# interface 'my_interface' do
# group 'main_screen'
# ...
#
- # @return []
+ # @return [API::Interface]
def group(value)
attributes[:group] = value
end
# The name of the interface. Used to reference the interface throughout
@@ -100,11 +105,11 @@
# @example
# interface do
# name 'my_interface'
# ...
#
- # @return []
+ # @return [API::Interface]
def name(value)
attributes[:name] = value
end
# Define the starting x position (column) of the interface.
@@ -120,11 +125,11 @@
# interface 'other_interface' do
# x { use('my_interface').east } # start on column 8, if
# # `my_interface` changes position,
# # `other_interface` will too.
#
- # @return []
+ # @return [API::Interface]
def x(value = 0, &block)
return attributes[:geometry][:x] = block if block_given?
Vedeu.log(out_of_bounds('x')) if x_out_of_bounds?(value)
@@ -145,11 +150,11 @@
# interface 'other_interface' do
# y { use('my_interface').north } # start on row/line 3, if
# ... # `my_interface` changes position,
# # `other_interface` will too.
#
- # @return []
+ # @return [API::Interface]
def y(value = 0, &block)
return attributes[:geometry][:y] = block if block_given?
Vedeu.log(out_of_bounds('y')) if y_out_of_bounds?(value)
@@ -164,11 +169,11 @@
# @example
# interface 'my_interface' do
# width 25
# ...
#
- # @return []
+ # @return [API::Interface]
def width(value)
Vedeu.log(out_of_bounds('width')) if x_out_of_bounds?(value)
attributes[:geometry][:width] = value
end
@@ -181,11 +186,11 @@
# @example
# interface 'my_interface' do
# height 8
# ...
#
- # @return []
+ # @return [API::Interface]
def height(value)
Vedeu.log(out_of_bounds('height')) if y_out_of_bounds?(value)
attributes[:geometry][:height] = value
end
@@ -199,10 +204,10 @@
# @example
# interface 'my_interface' do
# centred true
# ...
#
- # @return []
+ # @return [API::Interface]
def centred(value)
unless value.is_a?(TrueClass) || value.is_a?(FalseClass)
fail InvalidSyntax, 'Argument must be `true` or `false` for centred.'
end